Commit graph

147 commits

Author SHA1 Message Date
Victor Stinner 8898350076 Close #18957: The PYTHONFAULTHANDLER environment variable now only enables the
faulthandler module if the variable is non-empty. Same behaviour than other
variables like PYTHONDONTWRITEBYTECODE.
2013-09-08 11:36:23 +02:00
Victor Stinner 49fc8ece81 Issue #18203: Add _PyMem_RawStrdup() and _PyMem_Strdup()
Replace strdup() with _PyMem_RawStrdup() or _PyMem_Strdup(), depending if the
GIL is held or not.
2013-07-07 23:30:24 +02:00
Victor Stinner 0857ab4c77 (Merge 3.3) Issue #18343: faulthandler.register() now keeps the previous signal
handler when the function is called twice, so faulthandler.unregister()
restores correctly the original signal handler.
2013-07-02 00:17:14 +02:00
Victor Stinner 8d3795474e Issue #18343: faulthandler.register() now keeps the previous signal handler
when the function is called twice, so faulthandler.unregister() restores
correctly the original signal handler.
2013-07-02 00:14:56 +02:00
Victor Stinner 56cb12542d Issue #9566: Explicit downcast to fix compiler warnings on Win64 2012-10-31 00:33:57 +01:00
Jesus Cea 14c81aba50 #16135: Removal of OS/2 support (Modules/*) 2012-10-05 02:11:36 +02:00
Georg Brandl deb92b5b1b Closes #15969: rename new API to have consistent names in the faulthandler module. 2012-09-22 08:58:55 +02:00
Victor Stinner 3cc635dabb faulthandler: fix the handler of user signals
Restore the errno before calling the previous signal handler, and not after.
2012-08-09 02:43:41 +02:00
Victor Stinner 98a387b65f Fix the user signal handler of faulthandler
Don't exit the tstate is NULL to restore the errno and chain the signal handler
if needed.
2012-08-01 19:36:36 +02:00
Charles-François Natali 55bce63ea0 Issue #14154: Reimplement the bigmem test memory watchdog as a subprocess. 2012-03-24 10:06:23 +01:00
Victor Stinner a2477208c8 Issue #13874: read_null() of faulthandler uses volatile to avoid optimisation
Clang 3.0 removes "y = *x;" instruction if the optimisation level is 3.
2012-01-30 00:07:43 +01:00
Victor Stinner 1134b0dbbd Fix _PyFaulthandler_Fini() so it can be called before _PyFaulthandler_Init() 2012-01-10 22:44:11 +01:00
Martin v. Löwis bd928fef42 Rename _Py_identifier to _Py_IDENTIFIER. 2011-10-14 10:20:37 +02:00
Martin v. Löwis afe55bba33 Add API for static strings, primarily good for identifiers.
Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
2011-10-09 10:38:36 +02:00
Antoine Pitrou b244d075fb Fix compilation error under Windows 2011-10-04 13:00:02 +02:00
Antoine Pitrou 75e78b6c77 Use the faulthandler module's infrastructure to write a GIL-less
memory watchdog for timely stats collection.
2011-10-04 11:51:23 +02:00
Victor Stinner 639418812f Use the new Py_ARRAY_LENGTH macro 2011-09-29 00:42:28 +02:00
Victor Stinner 425fcd3045 Issue #12929: faulthandler now uses char* for arithmetic on pointers
instead of void*
2011-09-07 16:18:56 +02:00
Victor Stinner a9a9dab042 Issue #12550: Add chain optional argument to faulthandler.register()
Call the previous signal handler if chain is True.
2011-07-13 23:39:53 +02:00
Victor Stinner 0aafa4f1e2 faulthandler: add missing include, pthread.h, for FreeBSD 6 2011-06-29 23:28:02 +02:00
Victor Stinner 25095b2be6 Remove useless assignments
Warnings found by the the Clang Static Analyzer.
2011-05-26 13:47:08 +02:00
Victor Stinner 9b49304790 Close #12153: faulthandler, mark stack_overflow() as static 2011-05-23 12:29:10 +02:00
Victor Stinner 410dd7d357 Issue #12058: Minor edits to comments in faulthandler
Patch written by Éric Araujo.
2011-05-11 20:56:08 +02:00
Victor Stinner 00bc6ccb78 faulthandler: improve_sigabrt() on Visual Studio
Use _set_abort_behavior() + abort() instead of raise(SIGABRT) which may write
an error message and/or open a popup asking to report the fault.
2011-05-10 01:30:03 +02:00
Victor Stinner e0c9a7533c faulthandler: make quiet a gcc 4.6 warning (z was unused) 2011-05-09 14:44:26 +02:00
Victor Stinner 7bba62fd68 faulthandler: dump all threads by default
* Set the default value of all_threads arguments to True
 * Py_FatalError() dumps all threads, instead of only the current thread

Dump only the current thread is not reliable. In some cases, Python is unable
to retrieve the state of the current thread and so is unable to dump the
traceback. faulthandler keeps a reference to the interpreter and so is always
able to dump the traceback of all threads.
2011-05-07 12:43:00 +02:00
Victor Stinner c925617b54 faulthandler: save/restore errno in the two signal handlers 2011-05-07 12:20:11 +02:00
Victor Stinner cf2a807831 faulthandler: don't use sigprocmask()
It has an undefined behaviour with threads, only use pthread_sigmask() if
it is available (and not broken).
2011-04-19 23:30:57 +02:00
Victor Stinner a4de6d885f Improve faulthandler.enable(all_threads=True)
faulthandler.enable(all_threads=True) dumps the tracebacks even if it is not
possible to get the state of the current thread

Create also the get_thread_state() subfunction to factorize the code.
2011-04-09 00:47:23 +02:00
Victor Stinner c790a5346d faulthandler: dump_tracebacks_later() displays also the timeout 2011-04-08 13:39:59 +02:00
Victor Stinner 941893291a faulthandler: fix variable name, timeout_ms => timeout_us
The comment was already correct.
2011-04-08 13:00:31 +02:00
Victor Stinner de10f4054b faulthandler: one more time, fix usage of locks in the watchdog thread
* Write a new test to ensure that dump_tracebacks_later() still works if
   it was already called and then cancelled before
 * Don't use a variable to check the status of the thread, only rely on locks
 * The thread only releases cancel_event if it was able to acquire it (if
   the timer was interrupted)
 * The main thread always hold this lock. It is only released when
   faulthandler_thread() is interrupted until this thread exits, or at Python
   exit.
2011-04-08 12:57:06 +02:00
Victor Stinner cfa7123ef1 faulthandler: fix unregister() if it is called before register()
Fix a crash: don't read from NULL.
2011-04-08 12:48:15 +02:00
Victor Stinner ff4cd88266 faulthandler: fix compilating without threads 2011-04-07 11:50:25 +02:00
Victor Stinner 44e31baf95 faulthandler: we don't use (or need) SA_SIGINFO flag of sigaction() 2011-04-07 11:39:03 +02:00
Victor Stinner 9699440b57 faulthandler: check PyThreadState_Get() result in dump_tracebacks_later()
Cleanup also the code
2011-04-07 11:37:19 +02:00
Victor Stinner da9edae1f4 Issue #11753: faulthandler thread uses pthread_sigmask()
The thread must not receive any signal. If the thread receives a signal,
sem_timedwait() is interrupted and returns EINTR, but in this case,
PyThread_acquire_lock_timed() retries sem_timedwait() and the main thread is
not aware of the signal. The problem is that some tests expect that the main
thread receives the signal, not faulthandler handler, which should be
invisible.

On Linux, the signal looks to be received by the main thread, whereas on
FreeBSD, it can be any thread.
2011-04-04 11:05:21 +02:00
Victor Stinner 44378d46f6 Issue #11393: signal of user signal displays tracebacks even if tstate==NULL
* faulthandler_user() displays the tracebacks of all threads even if it is
   unable to get the state of the current thread
 * test_faulthandler: only release the GIL in test_gil_released() check
 * create check_signum() subfunction
2011-04-01 15:37:12 +02:00
Victor Stinner a01ca12a52 Issue #11393: Fix faulthandler.disable() and add a test 2011-04-01 12:56:17 +02:00
Victor Stinner d727e23243 Issue #11393: The fault handler handles also SIGABRT 2011-04-01 12:13:55 +02:00
Victor Stinner bc6a4db66d Issue #11393: fault handler uses raise(signum) for SIGILL on Windows 2011-04-01 12:08:57 +02:00
Victor Stinner f309134eff Issue #11393: fix usage of locks in faulthandler
* faulthandler_cancel_dump_tracebacks_later() is responsible to set running
   to zero (so we don't need the volatile keyword anymore)
 * release locks if PyThread_start_new_thread() fails

assert(thread.running == 0) was wrong in a corner case
2011-04-01 03:16:51 +02:00
Victor Stinner a4d4f1b4cb Issue #11393: New try to fix faulthandler_thread()
Always release the cancel join.

Fix also another corner case: _PyFaulthandler_Fini() called after setting
running variable to zero, but before releasing the join lock.
2011-04-01 03:00:05 +02:00
Victor Stinner 1c76b7f5e5 Issue #11393: Fix faulthandler_thread(): release cancel lock before join lock
If the thread releases the join lock before the cancel lock, the thread may
sometimes still be alive at cancel_dump_tracebacks_later() exit. So the cancel
lock may be destroyed while the thread is still alive, whereas the thread will
try to release the cancel lock, which just crash.

Another minor fix: the thread doesn't release the cancel lock if it didn't
acquire it.
2011-04-01 02:28:22 +02:00
Victor Stinner f048075079 Issue #11393: limit stack overflow test to 100 MB
Stop if the stack overflow doesn't occur after allocating 100 MB on the stack.
2011-03-31 11:34:08 +02:00
Victor Stinner 702624ecf7 Issue #11393: Fix the documentation (cancel_dump_traceback_later)
* dump_traceback_later() => dump_tracebacks_later()
 * cancel_dump_traceback_later() => cancel_dump_tracebacks_later()
2011-03-31 03:42:34 +02:00
Victor Stinner 024e37adcc Issue #11393: Add the new faulthandler module 2011-03-31 01:31:06 +02:00