[Ecls-list] Patch: remove sbrk() usage in handle_signal()
Josh Elsasser
josh at elsasser.org
Sat Oct 4 19:16:16 UTC 2008
The new stack overflow detection code uses sbrk(), which is not
portable. I'm guessing that it was used to detect if the signal
handler was executing on the alternate signal stack, if that is the
case then sigaltstack() would be the portable way to test for that.
diff --git src/c/unixint.d src/c/unixint.d
index 871c673..eef2ebc 100644
--- src/c/unixint.d
+++ src/c/unixint.d
@@ -220,15 +220,17 @@ handle_signal(int sig)
cl_error(1, condition);
break;
}
- case SIGSEGV:
-#ifdef SA_SIGINFO
- if (sbrk(0) < info->si_addr) {
+ case SIGSEGV: {
+#ifdef HAVE_SIGPROCMASK
+ stack_t stk;
+ if (0 == sigaltstack(NULL, &stk) && SS_ONSTACK & stk.ss_flags) {
GC_disable();
cl_error(3, @'ext::stack-overflow', @':type', @'ext::c-stack');
}
#endif
cl_error(1, @'ext::segmentation-violation');
break;
+ }
default:
FEerror("Serious signal ~D caught.", 1, MAKE_FIXNUM(sig));
}
More information about the ecl-devel
mailing list