[pypy-commit] pypy vmprof: (fijal, arigo) fix an obscure bug by saving/restoring errno, this is sooo obscure

fijal noreply at buildbot.pypy.org
Sat Mar 21 22:23:48 CET 2015


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: vmprof
Changeset: r76499:f5cbfdb05c32
Date: 2015-03-21 23:23 +0200
http://bitbucket.org/pypy/pypy/changeset/f5cbfdb05c32/

Log:	(fijal, arigo) fix an obscure bug by saving/restoring errno, this is
	sooo obscure

diff --git a/pypy/module/_vmprof/src/vmprof.c b/pypy/module/_vmprof/src/vmprof.c
--- a/pypy/module/_vmprof/src/vmprof.c
+++ b/pypy/module/_vmprof/src/vmprof.c
@@ -25,6 +25,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <errno.h>
 
 #define UNW_LOCAL_ONLY
 #include <libunwind.h>
@@ -200,10 +201,12 @@
 
 static void sigprof_handler(int sig_nr, siginfo_t* info, void *ucontext) {
     void* stack[MAX_STACK_DEPTH];
+    int saved_errno = errno;
     stack[0] = GetPC((ucontext_t*)ucontext);
     int depth = frame_forcer(get_stack_trace(stack+1, MAX_STACK_DEPTH-1, ucontext));
     depth++;  // To account for pc value in stack[0];
     prof_write_stacktrace(profile_file, stack, depth, 1);
+    errno = saved_errno;
 }
 
 /* *************************************************************


More information about the pypy-commit mailing list