From 5e98d1457d3080f84bbf3e0d71aaec90bdc46057 Mon Sep 17 00:00:00 2001 From: Bruce Allen Date: Thu, 10 Feb 2005 16:50:37 +0000 Subject: [PATCH] Added code to the scheduler so that it will dump core on SEGV. This is disabled by default. Having this is really useful if the scheduler is crashing some of the time. You can load the core dump file into a debugger to see where things are breaking. To use this, edit sched/main.C by hand and set #define DUMP_CORE_ON_SEGV 1 svn path=/trunk/boinc/; revision=5385 --- checkin_notes | 12 ++++++++++++ sched/main.C | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/checkin_notes b/checkin_notes index a5007b05e7..c8694f11dd 100755 --- a/checkin_notes +++ b/checkin_notes @@ -24462,3 +24462,15 @@ Bruce 10 Feb 2005 sched_send.C sched_util.[hC] +Bruce 10 Feb 2005 + Added code to the scheduler so that it will dump core on SEGV. This + is disabled by default. Having this + is really useful if the scheduler is crashing some of the time. You + can load the core dump file into a debugger to see where things are + breaking. To use this, edit sched/main.C by hand and set + #define DUMP_CORE_ON_SEGV 1 + + sched/ + main.C + + diff --git a/sched/main.C b/sched/main.C index a921525427..360dcd6597 100644 --- a/sched/main.C +++ b/sched/main.C @@ -30,6 +30,8 @@ using namespace std; #include #include #include +#include +#include #include "boinc_db.h" #include "parse.h" @@ -49,6 +51,11 @@ using namespace std; #include "fcgi_stdio.h" #endif +// Useful for debugging, if your cgi script keeps crashing. This +// makes it dump a core file that you can load into a debugger to see +// where the problem is. +#define DUMP_CORE_ON_SEGV 0 + #define DEBUG_LEVEL 999 #define MAX_FCGI_COUNT 20 @@ -122,6 +129,41 @@ int main() { srand(time(0)+getpid()); log_messages.set_debug_level(DEBUG_LEVEL); +#if DUMP_CORE_ON_SEGV + { + struct rlimit limit; + if (getrlimit(RLIMIT_CORE, &limit)) { + log_messages.printf(SCHED_MSG_LOG::CRITICAL, + "Unable to read resource limit for core dump size.\n" + ); + } + else { + char short_string[256], *short_message=short_string; + + short_message += sprintf(short_message,"Default resource limit for core dump size curr="); + if (limit.rlim_cur == RLIM_INFINITY) + short_message += sprintf(short_message,"Inf max="); + else + short_message += sprintf(short_message,"%d max=", (int)limit.rlim_cur); + + if (limit.rlim_max == RLIM_INFINITY) + short_message += sprintf(short_message,"Inf\n"); + else + short_message += sprintf(short_message,"%d\n", (int)limit.rlim_max); + + log_messages.printf(SCHED_MSG_LOG::DEBUG, "%s", short_string); + + // now set limit to the maximum allowed value + limit.rlim_cur=limit.rlim_max; + if (setrlimit(RLIMIT_CORE, &limit)) { + log_messages.printf(SCHED_MSG_LOG::CRITICAL, + "Unable to set current resource limit for core dump size to max value.\n" + ); + } + } + } +#endif + if (check_stop_sched()) { send_message("Project is temporarily shut down for maintenance", 3600); goto done; @@ -215,6 +257,7 @@ int main() { log_messages.printf(SCHED_MSG_LOG::CRITICAL, "can't write reply file\n"); exit(1); } + handle_request(fin, fout, *ssp, code_sign_key); fclose(fin); fclose(fout);