Issue12868
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.
Created on 2011-08-31 07:55 by rpointel, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
openbsd_sigaltstack-1.diff | neologix, 2011-09-01 18:09 | review |
Messages (19) | |||
---|---|---|---|
msg143251 - (view) | Author: Remi Pointel (rpointel) * | Date: 2011-08-31 07:55 | |
Hello, the test_stack_overflow failed on OpenBSD. Don't hesitate if you need more information. Details: $ ./python Lib/test/test_faulthandler.py test_disable (__main__.FaultHandlerTests) ... ok test_dump_traceback (__main__.FaultHandlerTests) ... ok test_dump_traceback_file (__main__.FaultHandlerTests) ... ok test_dump_traceback_threads (__main__.FaultHandlerTests) ... ok test_dump_traceback_threads_file (__main__.FaultHandlerTests) ... ok test_dump_tracebacks_later (__main__.FaultHandlerTests) ... ok test_dump_tracebacks_later_cancel (__main__.FaultHandlerTests) ... ok test_dump_tracebacks_later_file (__main__.FaultHandlerTests) ... ok test_dump_tracebacks_later_repeat (__main__.FaultHandlerTests) ... ok test_dump_tracebacks_later_twice (__main__.FaultHandlerTests) ... ok test_enable_file (__main__.FaultHandlerTests) ... ok test_enable_single_thread (__main__.FaultHandlerTests) ... ok test_fatal_error (__main__.FaultHandlerTests) ... ok test_gil_released (__main__.FaultHandlerTests) ... ok test_is_enabled (__main__.FaultHandlerTests) ... ok test_read_null (__main__.FaultHandlerTests) ... ok test_register (__main__.FaultHandlerTests) ... ok test_register_chain (__main__.FaultHandlerTests) ... ok test_register_file (__main__.FaultHandlerTests) ... ok test_register_threads (__main__.FaultHandlerTests) ... ok test_sigabrt (__main__.FaultHandlerTests) ... ok test_sigbus (__main__.FaultHandlerTests) ... ok test_sigfpe (__main__.FaultHandlerTests) ... ok test_sigill (__main__.FaultHandlerTests) ... ok test_sigsegv (__main__.FaultHandlerTests) ... ok test_stack_overflow (__main__.FaultHandlerTests) ... FAIL test_unregister (__main__.FaultHandlerTests) ... ok ====================================================================== FAIL: test_stack_overflow (__main__.FaultHandlerTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "Lib/test/test_faulthandler.py", line 187, in test_stack_overflow other_regex='unable to raise a stack overflow') File "Lib/test/test_faulthandler.py", line 105, in check_fatal_error self.assertRegex(output, regex) AssertionError: Regex didn't match: '^Fatal Python error: (?:Segmentation fault|Bus error)\n\nCurrent\\ thread\\ XXX:\n File "<string>", line 3 in <module>$|unable to raise a stack overflow' not found in '' ---------------------------------------------------------------------- Ran 27 tests in 16.938s FAILED (failures=1) Traceback (most recent call last): File "Lib/test/test_faulthandler.py", line 551, in <module> test_main() File "Lib/test/test_faulthandler.py", line 548, in test_main support.run_unittest(FaultHandlerTests) File "/home/remi/dev/cpython_test/Lib/test/support.py", line 1328, in run_unittest _run_suite(suite) File "/home/remi/dev/cpython_test/Lib/test/support.py", line 1303, in _run_suite raise TestFailed(err) test.support.TestFailed: Traceback (most recent call last): File "Lib/test/test_faulthandler.py", line 187, in test_stack_overflow other_regex='unable to raise a stack overflow') File "Lib/test/test_faulthandler.py", line 105, in check_fatal_error self.assertRegex(output, regex) AssertionError: Regex didn't match: '^Fatal Python error: (?:Segmentation fault|Bus error)\n\nCurrent\\ thread\\ XXX:\n File "<string>", line 3 in <module>$|unable to raise a stack overflow' not found in '' Thanks a lot, Remi. |
|||
msg143252 - (view) | Author: Remi Pointel (rpointel) * | Date: 2011-08-31 07:56 | |
Info: I read issue 12469 but I prefered to create new issue. |
|||
msg143267 - (view) | Author: Charles-François Natali (neologix) * | Date: 2011-08-31 17:30 | |
OpenBSD's threads are userland threads, and sigaltstack() doesn't work when the program is built with -pthread: http://marc.info/?l=openbsd-bugs&m=114323355014696&w=2 Note that POSIX warns about this: http://www.opengroup.org/onlinepubs/000095399/functions/sigaltstack.html """" Use of this function by library threads that are not bound to kernel-scheduled entities results in undefined behavior. """ I think we should skip this test on OpenBSD when Python is compiled with threads support. Out of curiosity, could you try this: $ ./python -c "import faulthandler; faulthandler.enable(); faulthandler._stack_overflow()"; echo $? And if you're motivated, you could try it again after having built python with './configure --without-threads'. |
|||
msg143269 - (view) | Author: Remi Pointel (rpointel) * | Date: 2011-08-31 17:59 | |
Hi, results: >Out of curiosity, could you try this: >$ ./python -c "import faulthandler; faulthandler.enable(); faulthandler._stack_overflow()"; echo $? $ ./python -c "import faulthandler; faulthandler.enable(); faulthandler._stack_overflow()"; echo $? zsh: illegal hardware instruction (core dumped) ./python -c 132 >And if you're motivated, you could try it again after having built python with './configure --without-threads'. It does not build completely, I have a problem if I add --without-threads: $ make [...] ./Modules/posixmodule.c:4582: undefined reference to `sched_get_priority_min' libpython3.3m.a(posixmodule.o)(.text+0x430b): In function `posix_sched_get_priority_max': ./Modules/posixmodule.c:4565: undefined reference to `sched_get_priority_max' collect2: ld returned 1 exit status *** Error code 1 It seems that it needs -pthread even if I precise --without-threads. Must I open a new ticket for this problem? Thanks for your help, Remi. |
|||
msg143271 - (view) | Author: STINNER Victor (vstinner) * | Date: 2011-08-31 18:04 | |
> I have a problem if I add --without-threads Yeah, it's a recent regression: I opened the issue #12871. I don't think that it's specific to OpenBSD. |
|||
msg143272 - (view) | Author: Remi Pointel (rpointel) * | Date: 2011-08-31 18:16 | |
> Yeah, it's a recent regression: I opened the issue #12871. I don't think that it's specific to OpenBSD. Thanks. |
|||
msg143278 - (view) | Author: Charles-François Natali (neologix) * | Date: 2011-08-31 20:51 | |
> It does not build completely, I have a problem if I add > --without-threads: Until this gets fixed, if you want to do a quick test, you could just remove the calls to sched_get_priority_(min|max): """ diff -r 0968acf0e6db Modules/posixmodule.c --- a/Modules/posixmodule.c Wed Aug 31 16:52:12 2011 +0200 +++ b/Modules/posixmodule.c Wed Aug 31 22:51:13 2011 +0200 @@ -4562,7 +4562,6 @@ if (!PyArg_ParseTuple(args, "i:sched_get_priority_max", &policy)) return NULL; - max = sched_get_priority_max(policy); if (max < 0) return posix_error(); return PyLong_FromLong(max); @@ -4579,7 +4578,6 @@ if (!PyArg_ParseTuple(args, "i:sched_get_priority_min", &policy)) return NULL; - min = sched_get_priority_min(policy); if (min < 0) return posix_error(); return PyLong_FromLong(min); """ That should allow you to rebuild with 'without-threads'. |
|||
msg143302 - (view) | Author: Remi Pointel (rpointel) * | Date: 2011-09-01 05:34 | |
Hi, without-threads, it segfault: $ ./python -c "import faulthandler; faulthandler.enable(); faulthandler._stack_overflow()"; echo $? Fatal Python error: Segmentation fault Current thread 0x0000000000000000: File "<string>", line 1 in <module> zsh: segmentation fault (core dumped) ./python -c 139 Thanks, Remi. |
|||
msg143303 - (view) | Author: Remi Pointel (rpointel) * | Date: 2011-09-01 05:39 | |
However, if I run test_faulthandler.py, it seems to be ok: $ ./python Lib/test/test_faulthandler.py test_disable (__main__.FaultHandlerTests) ... ok test_dump_traceback (__main__.FaultHandlerTests) ... ok test_dump_traceback_file (__main__.FaultHandlerTests) ... ok test_dump_traceback_threads (__main__.FaultHandlerTests) ... skipped 'need threads' test_dump_traceback_threads_file (__main__.FaultHandlerTests) ... skipped 'need threads' test_dump_tracebacks_later (__main__.FaultHandlerTests) ... skipped 'need faulthandler.dump_tracebacks_later()' test_dump_tracebacks_later_cancel (__main__.FaultHandlerTests) ... skipped 'need faulthandler.dump_tracebacks_later()' test_dump_tracebacks_later_file (__main__.FaultHandlerTests) ... skipped 'need faulthandler.dump_tracebacks_later()' test_dump_tracebacks_later_repeat (__main__.FaultHandlerTests) ... skipped 'need faulthandler.dump_tracebacks_later()' test_dump_tracebacks_later_twice (__main__.FaultHandlerTests) ... skipped 'need faulthandler.dump_tracebacks_later()' test_enable_file (__main__.FaultHandlerTests) ... ok test_enable_single_thread (__main__.FaultHandlerTests) ... ok test_fatal_error (__main__.FaultHandlerTests) ... ok test_gil_released (__main__.FaultHandlerTests) ... ok test_is_enabled (__main__.FaultHandlerTests) ... ok test_read_null (__main__.FaultHandlerTests) ... ok test_register (__main__.FaultHandlerTests) ... ok test_register_chain (__main__.FaultHandlerTests) ... ok test_register_file (__main__.FaultHandlerTests) ... ok test_register_threads (__main__.FaultHandlerTests) ... ok test_sigabrt (__main__.FaultHandlerTests) ... ok test_sigbus (__main__.FaultHandlerTests) ... ok test_sigfpe (__main__.FaultHandlerTests) ... ok test_sigill (__main__.FaultHandlerTests) ... ok test_sigsegv (__main__.FaultHandlerTests) ... ok test_stack_overflow (__main__.FaultHandlerTests) ... ok test_unregister (__main__.FaultHandlerTests) ... ok ---------------------------------------------------------------------- Ran 27 tests in 1.281s OK (skipped=7) Remi. |
|||
msg143308 - (view) | Author: Charles-François Natali (neologix) * | Date: 2011-09-01 06:45 | |
> without-threads, it segfault: > It's normal :-) _stack_overflow triggers - as it names implies - a stack overflow. However, as you can see in the output, faulthandler is now able to catch the SIGSEGV and display the backtrace (because it set up an alternate stack for the signal handler with sigaltstack). > However, if I run test_faulthandler.py, it seems to be ok: Yes: the test checks that the stack overflow was correctly caught by faulthandler. @Victor: can I commit the patch? |
|||
msg143311 - (view) | Author: STINNER Victor (vstinner) * | Date: 2011-09-01 08:18 | |
> @Victor: can I commit the patch? I don't like the skip message. It doesn't tell that the problem comes from sigaltstack() and it doesn't contain the issue number. I would expect something like: "Issue #12868: sigaltstack() doesn't work on OpenBSD if Python is compiled with pthread". Do you think that the bug will be fixed in OpenBSD? If yes, we should test the OpenBSD version in the skip. But it looks like OpenBSD thread implementation is very different than operating systems (e.g. threads are run in user space), and I don't expect a new implementation before some months/years... Anyway, skip the test if the right fix for this issue. Python cannot fix kernel/libc bugs. |
|||
msg143316 - (view) | Author: Steffen Daode Nurpmeso (sdaoden) | Date: 2011-09-01 10:50 | |
Heya. OpenBSD does support 1:1 threads via the RThread library since 2005, thanks to tedu@ and more fantastic guys! It about to be super-stable (one commit in 2011, last "real fix" in april 2010). (There is a techtalk from tedu@ (Ted Unangst) about this library on YouTube, btw.) |
|||
msg143320 - (view) | Author: STINNER Victor (vstinner) * | Date: 2011-09-01 12:22 | |
> OpenBSD does support 1:1 threads via the RThread library > since 2005, thanks to tedu@ and more fantastic guys! > It about to be super-stable (one commit in 2011, last "real > fix" in april 2010). > (There is a techtalk from tedu@ (Ted Unangst) about this library > on YouTube, btw.) Does Python support the RThread library? If not, is it planned? Is anyone working on it? In Python 3.3, you can use sys.thread_info to check which threading library is used. |
|||
msg143331 - (view) | Author: Steffen Daode Nurpmeso (sdaoden) | Date: 2011-09-01 15:50 | |
> In Python 3.3, you can use sys.thread_info to check which threading > library is used. Great! I didn't know that! |
|||
msg143332 - (view) | Author: STINNER Victor (vstinner) * | Date: 2011-09-01 15:58 | |
> Great! I didn't know that! It's a new feature of Python 3.3. I added it to skip a test on old FreeBDB, see test_threadsignal.py: ------------------------ USING_PTHREAD_COND = (sys.thread_info.name == 'pthread' and sys.thread_info.lock == 'mutex+cond') ... @unittest.skipIf(USING_PTHREAD_COND, 'POSIX condition variables cannot be interrupted') def test_lock_acquire_interruption(self): ------------------------ It is also used in test_os.py: --------------- if hasattr(sys, 'thread_info') and sys.thread_info.version: USING_LINUXTHREADS = sys.thread_info.version.startswith("linuxthreads") else: USING_LINUXTHREADS = False --------------- This "linux threads" check does already exist in Python 3.2, but is uses: --------------- libpthread = os.confstr("CS_GNU_LIBPTHREAD_VERSION") USING_LINUXTHREADS= libpthread.startswith("linuxthreads") --------------- See also the doc: http://docs.python.org/dev/library/sys.html#sys.thread_info |
|||
msg143336 - (view) | Author: Charles-François Natali (neologix) * | Date: 2011-09-01 18:09 | |
Here's a patch with an updated skip message. As for rthreads support, a quick search seems to indicate that its API is exactly the same as pthreads, and it's even binary compatible. Python will automatically use it when run on a OpenBSD system with rthreads enabled. |
|||
msg143353 - (view) | Author: STINNER Victor (vstinner) * | Date: 2011-09-01 20:21 | |
> As for rthreads support, a quick search seems to indicate that its API is > exactly the same as pthreads, and it's even binary compatible. Python will > automatically use it when run on a OpenBSD system with rthreads enabled. Well... not exactly. I asked on #openbsd: 22:07 < haypo> hi. what is the status of rthread? it looks like it is not available by default 22:14 < tp76> I might be wrong, but I don't think much work has been done on that in a while. 22:15 < haypo> tp76: i'm working on Python. Python is linked to pthread. I would like to know if we can link Python to rthread 22:16 < farhaven> no, you can't 22:17 < farhaven> rthreads is not (yet) a drop in replacement for pthreads and it basically works only if you use it for kernel threads 22:17 < farhaven> at least the manpage for rfork() advises against using it in userspace to create rthreads 22:18 < haypo> farhaven: does rthread have a userland API, similar to pthread, to manage threads? 22:18 < farhaven> nope, not that i know of 22:18 < haypo> i cannot find informations about rthread, only some old documents (2005) 22:18 < farhaven> afaik the only thing exposed to userland is rfork()'s RFTHREAD 22:19 < farhaven> i think tedu made a presentation about rthreads a while ago 22:19 < farhaven> but yeah, i wondered about that too one or two months ago 22:19 < farhaven> and it turned out, rthreads are not exactly usable :D Your last patch is correct. Go ahead. |
|||
msg143356 - (view) | Author: Roundup Robot (python-dev) | Date: 2011-09-01 21:07 | |
New changeset a29b72950795 by Charles-François Natali in branch 'default': Issue #12868: Skip test_faulthandler.test_stack_overflow() on OpenBSD: http://hg.python.org/cpython/rev/a29b72950795 |
|||
msg143357 - (view) | Author: Charles-François Natali (neologix) * | Date: 2011-09-01 21:11 | |
Committed. Rémi, thanks once again for this report! |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:21 | admin | set | github: 57077 |
2011-09-01 21:11:10 | neologix | set | status: open -> closed resolution: fixed messages: + msg143357 stage: needs patch -> resolved |
2011-09-01 21:07:26 | python-dev | set | nosy:
+ python-dev messages: + msg143356 |
2011-09-01 20:21:27 | vstinner | set | messages: + msg143353 |
2011-09-01 18:10:16 | neologix | set | files: - openbsd_sigaltstack.diff |
2011-09-01 18:09:36 | neologix | set | files:
+ openbsd_sigaltstack-1.diff messages: + msg143336 |
2011-09-01 15:58:47 | vstinner | set | messages: + msg143332 |
2011-09-01 15:50:58 | sdaoden | set | messages: + msg143331 |
2011-09-01 12:22:18 | vstinner | set | messages: + msg143320 |
2011-09-01 10:50:44 | sdaoden | set | nosy:
+ sdaoden messages: + msg143316 |
2011-09-01 08:18:19 | vstinner | set | messages: + msg143311 |
2011-09-01 06:45:09 | neologix | set | messages: + msg143308 |
2011-09-01 05:39:49 | rpointel | set | messages: + msg143303 |
2011-09-01 05:34:12 | rpointel | set | messages: + msg143302 |
2011-08-31 20:51:00 | neologix | set | messages: + msg143278 |
2011-08-31 18:37:50 | neologix | set | files:
+ openbsd_sigaltstack.diff keywords: + patch |
2011-08-31 18:16:29 | rpointel | set | messages: + msg143272 |
2011-08-31 18:04:19 | vstinner | set | messages: + msg143271 |
2011-08-31 17:59:35 | rpointel | set | messages: + msg143269 |
2011-08-31 17:30:09 | neologix | set | nosy:
+ vstinner, neologix messages: + msg143267 components: + Tests type: behavior stage: needs patch |
2011-08-31 07:56:11 | rpointel | set | messages: + msg143252 |
2011-08-31 07:55:32 | rpointel | create |