Author: Armin Rigo <[email protected]>
Branch: py3k-faulthandler
Changeset: r87358:4dee502cd268
Date: 2016-09-24 10:22 +0200
http://bitbucket.org/pypy/pypy/changeset/4dee502cd268/
Log: re-add _read_null()
diff --git a/pypy/module/faulthandler/__init__.py
b/pypy/module/faulthandler/__init__.py
--- a/pypy/module/faulthandler/__init__.py
+++ b/pypy/module/faulthandler/__init__.py
@@ -12,7 +12,7 @@
#
'dump_traceback': 'handler.dump_traceback',
#
-# '_read_null': 'interp_faulthandler.read_null',
+ '_read_null': 'handler.read_null',
# '_sigsegv': 'interp_faulthandler.sigsegv',
# '_sigfpe': 'interp_faulthandler.sigfpe',
# '_sigabrt': 'interp_faulthandler.sigabrt',
diff --git a/pypy/module/faulthandler/cintf.py
b/pypy/module/faulthandler/cintf.py
--- a/pypy/module/faulthandler/cintf.py
+++ b/pypy/module/faulthandler/cintf.py
@@ -40,3 +40,12 @@
pypy_faulthandler_dump_traceback = direct_llexternal(
'pypy_faulthandler_dump_traceback', [rffi.INT, rffi.INT], lltype.Void)
+
+# for tests...
+
+pypy_faulthandler_read_null = direct_llexternal(
+ 'pypy_faulthandler_read_null', [], lltype.Void)
+
+pypy_faulthandler_read_null_releasegil = direct_llexternal(
+ 'pypy_faulthandler_read_null', [], lltype.Void,
+ _nowrapper=False, releasegil=True)
diff --git a/pypy/module/faulthandler/dumper.py
b/pypy/module/faulthandler/dumper.py
--- a/pypy/module/faulthandler/dumper.py
+++ b/pypy/module/faulthandler/dumper.py
@@ -41,7 +41,7 @@
_dump(pycode.co_filename)
_dump('" in ')
_dump(pycode.co_name)
- _dump(" starting at line ")
+ _dump(", from line ")
_dump_int(pycode.co_firstlineno)
_dump("\n")
return 1
diff --git a/pypy/module/faulthandler/faulthandler.c
b/pypy/module/faulthandler/faulthandler.c
--- a/pypy/module/faulthandler/faulthandler.c
+++ b/pypy/module/faulthandler/faulthandler.c
@@ -113,6 +113,7 @@
if (handler->signum == signum)
break;
}
+ /* If not found, we use the SIGSEGV handler (the last one in the list) */
/* restore the previous handler */
if (handler->enabled) {
@@ -173,8 +174,12 @@
if (fatal_error.initialized) {
pypy_faulthandler_disable();
fatal_error.initialized = 0;
- free(stack.ss_sp);
- stack.ss_sp = NULL;
+ if (stack.ss_sp) {
+ stack.ss_flags = SS_DISABLE;
+ sigaltstack(&stack, NULL);
+ free(stack.ss_sp);
+ stack.ss_sp = NULL;
+ }
}
}
@@ -238,18 +243,18 @@
}
-#if 0
-int
-pypy_faulthandler_read_null(void)
+/* for tests... */
+
+RPY_EXTERN
+int pypy_faulthandler_read_null(void)
{
- volatile int *x;
- volatile int y;
+ int *volatile x;
x = NULL;
- y = *x;
- return y;
+ return *x;
}
+#if 0
void
pypy_faulthandler_sigsegv(void)
{
diff --git a/pypy/module/faulthandler/faulthandler.h
b/pypy/module/faulthandler/faulthandler.h
--- a/pypy/module/faulthandler/faulthandler.h
+++ b/pypy/module/faulthandler/faulthandler.h
@@ -15,8 +15,9 @@
RPY_EXTERN void pypy_faulthandler_dump_traceback(int fd, int all_threads);
+
+RPY_EXTERN int pypy_faulthandler_read_null(void);
/*
-RPY_EXTERN int pypy_faulthandler_read_null(void);
RPY_EXTERN void pypy_faulthandler_sigsegv(void);
RPY_EXTERN int pypy_faulthandler_sigfpe(void);
RPY_EXTERN void pypy_faulthandler_sigabrt();
diff --git a/pypy/module/faulthandler/handler.py
b/pypy/module/faulthandler/handler.py
--- a/pypy/module/faulthandler/handler.py
+++ b/pypy/module/faulthandler/handler.py
@@ -124,3 +124,12 @@
"""dump the traceback of the current thread into file
including all threads if all_threads is True"""
space.fromcache(Handler).dump_traceback(w_file, all_threads)
+
+# for tests...
+
+@unwrap_spec(release_gil=bool)
+def read_null(space, release_gil):
+ if release_gil:
+ cintf.pypy_faulthandler_read_null_releasegil()
+ else:
+ cintf.pypy_faulthandler_read_null()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit