classification
Title: Unlimited loop in sysconfig._parse_makefile()
Type: Stage:
Components: Library (Lib) Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: haypo, python-dev
Priority: normal Keywords: patch

Created on 2011-05-13 13:58 by haypo, last changed 2011-05-24 21:40 by haypo. This issue is now closed.

Files
File name Uploaded Description Edit
Makefile.loop haypo, 2011-05-13 14:04
sysconfig.patch haypo, 2011-05-24 13:15 review
Messages (5)
msg135909 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2011-05-13 13:58
$ ./python -c "import sysconfig; sysconfig._parse_makefile('Makefile.loop')"

It loops on the following variables:

'DESTSHARED'='$(BINLIBDEST)/lib-dynload'
'INCLDIRSTOMAKE'='$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)'
'CONFINCLUDEPY'='$(CONFINCLUDEDIR)/python$(LDVERSION)'
'DESTLIB'='$(LIBDEST)'
'INCLUDEPY'='$(INCLUDEDIR)/python$(LDVERSION)'
'MANDIR'='${datarootdir}/man'
'DESTDIRS'='$(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)'
'CONFINCLUDEDIR'='$(exec_prefix)/include'
'exec_prefix'='${prefix}'
'LIBDIR'='${exec_prefix}/lib'
'LIBDEST'='$(SCRIPTDIR)/python$(VERSION)'
'INCLUDEDIR'='${prefix}/include'
'BINDIR'='${exec_prefix}/bin'
'LIBPC'='$(LIBDIR)/pkgconfig'
'datarootdir'='${prefix}/share'
'SCRIPTDIR'='$(prefix)/lib'
'BINLIBDEST'='$(LIBDIR)/python$(VERSION)'
'LIBPL'='$(LIBDEST)/config-$(LDVERSION)'
'MACHDESTLIB'='$(BINLIBDEST)'

I had the bug while trying to debug #6011.
msg135910 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2011-05-13 14:05
My OS is Debian Sid. Important note: I use LC_ALL=C and so ASCII locale encoding.
msg135945 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2011-05-13 22:37
Oh, the problem is that the prefix variable value is seen as "bogus" ($/home/haypo/...: $ is a typo made by me!) and the variable is removed from variables. But other variables depend on the prefix and so we have an unlimited loop.

Possibles fixes:
 - raise an exception if a variable is "bogus"
 - detect loops: ensure that at least was removed during a step (and raise an exception if not)
 - keep "bogus" variables (add them to done)
msg136749 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2011-05-24 13:15
distutils.sysconfig has also a parse_makefile() function, but it doesn't have the bug.

Attached patch fixes this issue: keep "bogus" variables unchanged and adds tests for _parse_makefile().
msg136795 - (view) Author: Roundup Robot (python-dev) Date: 2011-05-24 21:38
New changeset 4a7bb2ef636a by Victor Stinner in branch '3.2':
Issue #12070: Fix the Makefile parser of the sysconfig module to handle
http://hg.python.org/cpython/rev/4a7bb2ef636a

New changeset 98ff40ee0106 by Victor Stinner in branch 'default':
(Merge 3.2) Issue #12070: Fix the Makefile parser of the sysconfig module to
http://hg.python.org/cpython/rev/98ff40ee0106
History
Date User Action Args
2011-05-24 21:40:06hayposetstatus: open -> closed
resolution: fixed
2011-05-24 21:38:26python-devsetnosy: + python-dev
messages: + msg136795
2011-05-24 13:15:30hayposetfiles: + sysconfig.patch
keywords: + patch
messages: + msg136749

versions: + Python 3.2
2011-05-13 22:37:21hayposetmessages: + msg135945
2011-05-13 14:05:28hayposetmessages: + msg135910
2011-05-13 14:04:52hayposetfiles: + Makefile.loop
2011-05-13 13:58:18haypocreate