File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -1709,6 +1709,7 @@ Artur Zaprzala
1709
1709
Mike Zarnstorff
1710
1710
Yury V. Zaytsev
1711
1711
Siebren van der Zee
1712
+ Christophe Zeitouny
1712
1713
Nickolai Zeldovich
1713
1714
Yuxiao Zeng
1714
1715
Uwe Zessin
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ Core and Builtins
27
27
Library
28
28
-------
29
29
30
+ - bpo-29884: faulthandler: Restore the old sigaltstack during teardown.
31
+ Patch by Christophe Zeitouny.
32
+
30
33
- bpo-25455: Fixed crashes in repr of recursive buffered file-like objects.
31
34
32
35
- bpo-29800: Fix crashes in partial.__repr__ if the keys of partial.keywords
Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ static const size_t faulthandler_nsignals = \
124
124
125
125
#ifdef HAVE_SIGALTSTACK
126
126
static stack_t stack ;
127
+ static stack_t old_stack ;
127
128
#endif
128
129
129
130
@@ -1310,7 +1311,7 @@ int _PyFaulthandler_Init(void)
1310
1311
stack .ss_size = SIGSTKSZ ;
1311
1312
stack .ss_sp = PyMem_Malloc (stack .ss_size );
1312
1313
if (stack .ss_sp != NULL ) {
1313
- err = sigaltstack (& stack , NULL );
1314
+ err = sigaltstack (& stack , & old_stack );
1314
1315
if (err ) {
1315
1316
PyMem_Free (stack .ss_sp );
1316
1317
stack .ss_sp = NULL ;
@@ -1366,6 +1367,20 @@ void _PyFaulthandler_Fini(void)
1366
1367
faulthandler_disable ();
1367
1368
#ifdef HAVE_SIGALTSTACK
1368
1369
if (stack .ss_sp != NULL ) {
1370
+ /* Fetch the current alt stack */
1371
+ stack_t current_stack ;
1372
+ if (sigaltstack (NULL , & current_stack ) == 0 ) {
1373
+ if (current_stack .ss_sp == stack .ss_sp ) {
1374
+ /* The current alt stack is the one that we installed.
1375
+ It is safe to restore the old stack that we found when
1376
+ we installed ours */
1377
+ sigaltstack (& old_stack , NULL );
1378
+ } else {
1379
+ /* Someone switched to a different alt stack and didn't
1380
+ restore ours when they were done (if they're done).
1381
+ There's not much we can do in this unlikely case */
1382
+ }
1383
+ }
1369
1384
PyMem_Free (stack .ss_sp );
1370
1385
stack .ss_sp = NULL ;
1371
1386
}
You can’t perform that action at this time.
0 commit comments