This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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: python-dev, vstinner
Priority: normal Keywords: patch

Created on 2011-05-13 13:58 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Makefile.loop vstinner, 2011-05-13 14:04
sysconfig.patch vstinner, 2011-05-24 13:15 review
Messages (5)
msg135909 - (view) Author: STINNER Victor (vstinner) * (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 (vstinner) * (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 (vstinner) * (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 (vstinner) * (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) (Python triager) 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
2022-04-11 14:57:17adminsetgithub: 56279
2011-05-24 21:40:06vstinnersetstatus: open -> closed
resolution: fixed
2011-05-24 21:38:26python-devsetnosy: + python-dev
messages: + msg136795
2011-05-24 13:15:30vstinnersetfiles: + sysconfig.patch
keywords: + patch
messages: + msg136749

versions: + Python 3.2
2011-05-13 22:37:21vstinnersetmessages: + msg135945
2011-05-13 14:05:28vstinnersetmessages: + msg135910
2011-05-13 14:04:52vstinnersetfiles: + Makefile.loop
2011-05-13 13:58:18vstinnercreate