mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
Detect stack overflows
Previously, if the Nix evaluator gets a stack overflow due to a deep or infinite recursion in the Nix expression, the user gets an unhelpful message ("Segmentation fault") that doesn't indicate that the problem is in the user's code rather than Nix itself. Now it prints: error: stack overflow (possible infinite recursion) This only works on x86_64-linux and i686-linux. Fixes #35.
This commit is contained in:
parent
e87d1a63bd
commit
70e68e0ec6
3 changed files with 80 additions and 1 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if HAVE_BOEHMGC
|
||||
#include <gc/gc.h>
|
||||
|
@ -100,6 +101,9 @@ string getArg(const string & opt,
|
|||
}
|
||||
|
||||
|
||||
void detectStackOverflow();
|
||||
|
||||
|
||||
/* Initialize and reorder arguments, then call the actual argument
|
||||
processor. */
|
||||
static void initAndRun(int argc, char * * argv)
|
||||
|
@ -131,6 +135,9 @@ static void initAndRun(int argc, char * * argv)
|
|||
if (sigaction(SIGCHLD, &act, 0))
|
||||
throw SysError("resetting SIGCHLD");
|
||||
|
||||
/* Register a SIGSEGV handler to detect stack overflows. */
|
||||
detectStackOverflow();
|
||||
|
||||
/* There is no privacy in the Nix system ;-) At least not for
|
||||
now. In particular, store objects should be readable by
|
||||
everybody. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue