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 @@ -1716,6 +1716,7 @@ Artur Zaprzala
1716
1716
Mike Zarnstorff
1717
1717
Yury V. Zaytsev
1718
1718
Siebren van der Zee
1719
+ Christophe Zeitouny
1719
1720
Nickolai Zeldovich
1720
1721
Yuxiao Zeng
1721
1722
Uwe Zessin
Original file line number Diff line number Diff line change @@ -287,6 +287,9 @@ Extension Modules
287
287
Library
288
288
-------
289
289
290
+ - bpo-29884: faulthandler: Restore the old sigaltstack during teardown.
291
+ Patch by Christophe Zeitouny.
292
+
290
293
- bpo-25455: Fixed crashes in repr of recursive buffered file-like objects.
291
294
292
295
- 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
@@ -1317,7 +1318,7 @@ int _PyFaulthandler_Init(void)
1317
1318
stack .ss_size = SIGSTKSZ ;
1318
1319
stack .ss_sp = PyMem_Malloc (stack .ss_size );
1319
1320
if (stack .ss_sp != NULL ) {
1320
- err = sigaltstack (& stack , NULL );
1321
+ err = sigaltstack (& stack , & old_stack );
1321
1322
if (err ) {
1322
1323
PyMem_Free (stack .ss_sp );
1323
1324
stack .ss_sp = NULL ;
@@ -1373,6 +1374,20 @@ void _PyFaulthandler_Fini(void)
1373
1374
faulthandler_disable ();
1374
1375
#ifdef HAVE_SIGALTSTACK
1375
1376
if (stack .ss_sp != NULL ) {
1377
+ /* Fetch the current alt stack */
1378
+ stack_t current_stack ;
1379
+ if (sigaltstack (NULL , & current_stack ) == 0 ) {
1380
+ if (current_stack .ss_sp == stack .ss_sp ) {
1381
+ /* The current alt stack is the one that we installed.
1382
+ It is safe to restore the old stack that we found when
1383
+ we installed ours */
1384
+ sigaltstack (& old_stack , NULL );
1385
+ } else {
1386
+ /* Someone switched to a different alt stack and didn't
1387
+ restore ours when they were done (if they're done).
1388
+ There's not much we can do in this unlikely case */
1389
+ }
1390
+ }
1376
1391
PyMem_Free (stack .ss_sp );
1377
1392
stack .ss_sp = NULL ;
1378
1393
}
You can’t perform that action at this time.
0 commit comments