cpython
cpython copied to clipboard
`sysconfig --generate-posix-vars` can hang on cyclic variable definitions
Bug report
Bug description:
This loop can run forever if there's a cycle in the Makefile variable definitions: https://github.com/python/cpython/blob/5334732f9c8a44722e4b339f4bb837b5b0226991/Lib/sysconfig/main.py#L79
To reproduce:
make clean
echo 'foo=$(foo)' > ./Modules/Setup.local
./configure
make # hangs forever
Or more minimally:
make clean
echo 'foo=$(foo)' > ./Modules/Setup.local
make Makefile
./python -m sysconfig --generate-posix-vars # hangs forever
Longer cycles are also possible, e.g. v1=$(v2), v2=$(v3), ...., v999=$(v1).
Note that this is less of an issue if the recursive variable definition gets expanded in the Makefile before python -m sysconfig --generate-posix-vars gets invoked. In that case, Make will detect the cycle and exit before the infinite loop occurs.
@serhiy-storchaka you may be interested, this is very similar to #136073
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux