Hello,
I'm testing new Python releases in Fedora Linux with the aim to integrate libraries in time for the final release next year.
Working on the dependency tree, I attempted to build setproctitle and failed with segfault happening on test_clear_segfault.
Upon more investigation, the segfault happens when trying to access environ[0], leading me to suspicion environ itself is not accessible.
I tried to print the value of environ with:
spt_debug("environ pointer itself: %p", (void*)environ);
---
output: [SPT]: environ pointer itself: (nil)
Adding the lines:
if (!environ) {
spt_debug("environ is NULL");
goto exit;
}
above trying to access the first element of the environ array seems to be solving an issue.
Let me know if this is the right reasoning and the proposed fix is indeed a solution.
I'll be happy to send the PR on the timeline that's convenient to you (I understand not everybody cares about Python alphas).
Steps to reproduce:
- create a Python 3.15 virtual environment and install setuptools
python setup.py build && python -m pip install .
python and
>>> import os
>>> from setproctitle import setproctitle
>>> os.environ.clear()
>>> setproctitle("Test")
Debug output with my fix and Python 3.15:
[SPT]: reading argc/argv from Python main
[SPT]: found 1 arguments
[SPT]: walking from environ to look for the arguments
[SPT]: environ pointer itself: (nil)
[SPT]: environ is NULL
[SPT]: couldn't find argv from environ
[SPT]: get_argc_argv failed
[SPT]: failed to initialize setproctitle
Debug output with Python 3.14:
[SPT]: reading argc/argv from Python main
[SPT]: found 1 arguments
[SPT]: walking from environ to look for the arguments
[SPT]: found environ at 0x55e9588224e0
[SPT]: argv[0] should be at 0x55e9588224d9
[SPT]: argv[0] '' doesn't match 'python'
[SPT]: couldn't find argv from environ
[SPT]: get_argc_argv failed
[SPT]: failed to initialize setproctitle
Hello,
I'm testing new Python releases in Fedora Linux with the aim to integrate libraries in time for the final release next year.
Working on the dependency tree, I attempted to build setproctitle and failed with segfault happening on
test_clear_segfault.Upon more investigation, the segfault happens when trying to access
environ[0], leading me to suspicionenvironitself is not accessible.I tried to print the value of
environwith:Adding the lines:
above trying to access the first element of the
environarray seems to be solving an issue.Let me know if this is the right reasoning and the proposed fix is indeed a solution.
I'll be happy to send the PR on the timeline that's convenient to you (I understand not everybody cares about Python alphas).
Steps to reproduce:
python setup.py build && python -m pip install .pythonandDebug output with my fix and Python 3.15:
Debug output with Python 3.14: