Message106801
Attached patch implements an handler for the signal SIGSEGV. It uses its own stack to be able to allocate memory on the stack (eg. call a function), even on stack overflow.
The patch requires sigaction() and sigaltstack() functions, but I didn't patched configure.in script. These functions are available on Linux, but should be available on other UNIX OSes.
segfault() signal handler supposes that the thread state is consistent (interp->frame chained list). It calls indirectly PyUnicode_EncodeUTF8() and so call PyBytes_FromStringAndSize() which allocates memory on the heap. It clears PyUnicode "defenc" attribute (the result of PyUnicode_EncodeUTF8()) to free directly the memory.
To test it, try some scripts in Lib/test/crashers/.
One example:
--------------------
$ ./python Lib/test/crashers/recursive_call.py
Fatal Python error: segmentation fault
Traceback (most recent call first):
File "Lib/test/crashers/recursive_call.py", line 12, depth 15715
File "Lib/test/crashers/recursive_call.py", line 12, depth 15714
File "Lib/test/crashers/recursive_call.py", line 12, depth 15713
...
File "Lib/test/crashers/recursive_call.py", line 12, depth 3
File "Lib/test/crashers/recursive_call.py", line 12, depth 2
File "Lib/test/crashers/recursive_call.py", line 9, depth 1
Segmentation fault
-------------------- |
|
Date |
User |
Action |
Args |
2010-05-31 19:01:25 | vstinner | set | recipients:
+ vstinner |
2010-05-31 19:01:25 | vstinner | set | messageid: <1275332485.24.0.0853481149333.issue8863@psf.upfronthosting.co.za> |
2010-05-31 19:01:23 | vstinner | link | issue8863 messages |
2010-05-31 19:01:23 | vstinner | create | |
|