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 @@ -1679,6 +1679,7 @@ Artur Zaprzala
1679
1679
Mike Zarnstorff
1680
1680
Yury V. Zaytsev
1681
1681
Siebren van der Zee
1682
+ Christophe Zeitouny
1682
1683
Nickolai Zeldovich
1683
1684
Yuxiao Zeng
1684
1685
Uwe Zessin
Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ Extension Modules
46
46
Library
47
47
-------
48
48
49
+ - bpo-29884: faulthandler: Restore the old sigaltstack during teardown.
50
+ Patch by Christophe Zeitouny.
51
+
49
52
- bpo-25455: Fixed crashes in repr of recursive buffered file-like objects.
50
53
51
54
- 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 unsigned char 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
@@ -1148,7 +1149,7 @@ int _PyFaulthandler_Init(void)
1148
1149
stack .ss_size = SIGSTKSZ ;
1149
1150
stack .ss_sp = PyMem_Malloc (stack .ss_size );
1150
1151
if (stack .ss_sp != NULL ) {
1151
- err = sigaltstack (& stack , NULL );
1152
+ err = sigaltstack (& stack , & old_stack );
1152
1153
if (err ) {
1153
1154
PyMem_Free (stack .ss_sp );
1154
1155
stack .ss_sp = NULL ;
@@ -1204,6 +1205,20 @@ void _PyFaulthandler_Fini(void)
1204
1205
faulthandler_disable ();
1205
1206
#ifdef HAVE_SIGALTSTACK
1206
1207
if (stack .ss_sp != NULL ) {
1208
+ /* Fetch the current alt stack */
1209
+ stack_t current_stack ;
1210
+ if (sigaltstack (NULL , & current_stack ) == 0 ) {
1211
+ if (current_stack .ss_sp == stack .ss_sp ) {
1212
+ /* The current alt stack is the one that we installed.
1213
+ It is safe to restore the old stack that we found when
1214
+ we installed ours */
1215
+ sigaltstack (& old_stack , NULL );
1216
+ } else {
1217
+ /* Someone switched to a different alt stack and didn't
1218
+ restore ours when they were done (if they're done).
1219
+ There's not much we can do in this unlikely case */
1220
+ }
1221
+ }
1207
1222
PyMem_Free (stack .ss_sp );
1208
1223
stack .ss_sp = NULL ;
1209
1224
}
You can’t perform that action at this time.
0 commit comments