Browse Source

If __BFGMINER_SEGFAULT_ERRQUIT is set in the environment, segfault on non-zero quit()s

Luke Dashjr 13 years ago
parent
commit
fd55df8bf2
1 changed files with 9 additions and 0 deletions
  1. 9 0
      cgminer.c

+ 9 - 0
cgminer.c

@@ -4361,6 +4361,15 @@ void quit(int status, const char *format, ...)
 	fprintf(stderr, "\n");
 	fflush(stderr);
 
+	if (status) {
+		const char *ev = getenv("__BFGMINER_SEGFAULT_ERRQUIT");
+		if (unlikely(ev && ev[0] && ev[0] != '0')) {
+			const char **p = NULL;
+			// NOTE debugger can bypass with: p = &p
+			*p = format;  // Segfault, hopefully dumping core
+		}
+	}
+
 #if defined(unix)
 	if (forkpid > 0) {
 		kill(forkpid, SIGTERM);