Fossil SCM

More information in the log file for signal handlers. Include the phase of operation as part of the log message.

drh 2021-08-08 18:20 trunk
Commit 48c06b0a134b4b3188eac410b50a8173386cbcb9b390381c663be1ad23282d4c
2 files changed +1 +20 -5
--- src/backoffice.c
+++ src/backoffice.c
@@ -484,10 +484,11 @@
484484
int lastWarning = 0;
485485
int warningDelay = 30;
486486
static int once = 0;
487487
488488
if( sqlite3_db_readonly(g.db, 0) ) return;
489
+ g.zPhase = "backoffice";
489490
backoffice_error_check_one(&once);
490491
idSelf = backofficeProcessId();
491492
while(1){
492493
tmNow = time(0);
493494
db_begin_write();
494495
--- src/backoffice.c
+++ src/backoffice.c
@@ -484,10 +484,11 @@
484 int lastWarning = 0;
485 int warningDelay = 30;
486 static int once = 0;
487
488 if( sqlite3_db_readonly(g.db, 0) ) return;
 
489 backoffice_error_check_one(&once);
490 idSelf = backofficeProcessId();
491 while(1){
492 tmNow = time(0);
493 db_begin_write();
494
--- src/backoffice.c
+++ src/backoffice.c
@@ -484,10 +484,11 @@
484 int lastWarning = 0;
485 int warningDelay = 30;
486 static int once = 0;
487
488 if( sqlite3_db_readonly(g.db, 0) ) return;
489 g.zPhase = "backoffice";
490 backoffice_error_check_one(&once);
491 idSelf = backofficeProcessId();
492 while(1){
493 tmNow = time(0);
494 db_begin_write();
495
+20 -5
--- src/main.c
+++ src/main.c
@@ -143,10 +143,11 @@
143143
144144
struct Global {
145145
int argc; char **argv; /* Command-line arguments to the program */
146146
char *nameOfExe; /* Full path of executable. */
147147
const char *zErrlog; /* Log errors to this file, if not NULL */
148
+ const char *zPhase; /* Phase of operation, for use by the error log */
148149
int isConst; /* True if the output is unchanging & cacheable */
149150
const char *zVfsName; /* The VFS to use for database connections */
150151
sqlite3 *db; /* The connection to the databases */
151152
sqlite3 *dbConfig; /* Separate connection for global_config table */
152153
char *zAuxSchema; /* Main repository aux-schema */
@@ -673,10 +674,11 @@
673674
int fossil_main(int argc, char **argv){
674675
const char *zCmdName = "unknown";
675676
const CmdOrPage *pCmd = 0;
676677
int rc;
677678
679
+ g.zPhase = "init";
678680
#if !defined(_WIN32_WCE)
679681
if( fossil_getenv("FOSSIL_BREAK") ){
680682
if( isatty(0) && isatty(2) ){
681683
fprintf(stderr,
682684
"attach debugger to process %d and press any key to continue.\n",
@@ -957,11 +959,13 @@
957959
rc = TH_OK;
958960
}
959961
if( rc==TH_OK || rc==TH_RETURN || rc==TH_CONTINUE ){
960962
if( rc==TH_OK || rc==TH_RETURN ){
961963
#endif
964
+ g.zPhase = pCmd->zName;
962965
pCmd->xFunc();
966
+ g.zPhase = "shutdown";
963967
#ifdef FOSSIL_ENABLE_TH1_HOOKS
964968
}
965969
if( !g.isHTTP && !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
966970
Th_CommandNotify(pCmd->zName, pCmd->eCmdFlags);
967971
}
@@ -1527,17 +1531,17 @@
15271531
size_t i;
15281532
Blob out;
15291533
size = backtrace(array, sizeof(array)/sizeof(array[0]));
15301534
strings = backtrace_symbols(array, size);
15311535
blob_init(&out, 0, 0);
1532
- blob_appendf(&out, "Segfault");
1536
+ blob_appendf(&out, "Segfault during %s", g.zPhase);
15331537
for(i=0; i<size; i++){
15341538
blob_appendf(&out, "\n(%d) %s", i, strings[i]);
15351539
}
15361540
fossil_panic("%s", blob_str(&out));
15371541
#else
1538
- fossil_panic("Segfault");
1542
+ fossil_panic("Segfault during %s", g.zPhase);
15391543
#endif
15401544
exit(1);
15411545
}
15421546
15431547
/*
@@ -1548,10 +1552,11 @@
15481552
#ifndef _WIN32
15491553
if( g.fAnyTrace ){
15501554
fprintf(stderr,"/***** sigpipe received by subprocess %d ****\n", getpid());
15511555
}
15521556
#endif
1557
+ g.zPhase = "sigpipe shutdown";
15531558
db_panic_close();
15541559
exit(1);
15551560
}
15561561
15571562
/*
@@ -1620,10 +1625,11 @@
16201625
char *zPath = NULL;
16211626
int i;
16221627
const CmdOrPage *pCmd = 0;
16231628
const char *zBase = g.zRepositoryName;
16241629
1630
+ g.zPhase = "process_one_web_page";
16251631
#if !defined(_WIN32)
16261632
signal(SIGSEGV, sigsegv_handler);
16271633
#endif
16281634
16291635
/* Handle universal query parameters */
@@ -2022,10 +2028,11 @@
20222028
rc = TH_OK;
20232029
}
20242030
if( rc==TH_OK || rc==TH_RETURN || rc==TH_CONTINUE ){
20252031
if( rc==TH_OK || rc==TH_RETURN ){
20262032
#endif
2033
+ g.zPhase = pCmd->zName;
20272034
pCmd->xFunc();
20282035
#ifdef FOSSIL_ENABLE_TH1_HOOKS
20292036
}
20302037
if( !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
20312038
Th_WebpageNotify(pCmd->zName+1, pCmd->eCmdFlags);
@@ -2035,10 +2042,11 @@
20352042
#endif
20362043
}
20372044
20382045
/* Return the result.
20392046
*/
2047
+ g.zPhase = "web-page reply";
20402048
cgi_reply();
20412049
}
20422050
20432051
/* If the CGI program contains one or more lines of the form
20442052
**
@@ -2785,12 +2793,13 @@
27852793
#ifndef _WIN32
27862794
static int nAlarmSeconds = 0;
27872795
static void sigalrm_handler(int x){
27882796
sqlite3_uint64 tmUser = 0, tmKernel = 0;
27892797
fossil_cpu_times(&tmUser, &tmKernel);
2790
- fossil_panic("Timeout after %d seconds - user %,llu µs, sys %,llu µs",
2791
- nAlarmSeconds, tmUser, tmKernel);
2798
+ fossil_panic("Timeout after %d seconds during %s"
2799
+ " - user %,llu µs, sys %,llu µs",
2800
+ nAlarmSeconds, g.zPhase, tmUser, tmKernel);
27922801
}
27932802
#endif
27942803
27952804
/*
27962805
** Arrange to timeout using SIGALRM after N seconds. Or if N==0, cancel
@@ -3240,11 +3249,11 @@
32403249
@ <p>Generate a message to the <a href="%R/errorlog">error log</a>
32413250
@ by clicking on one of the following cases:
32423251
}else{
32433252
@ <p>This is the test page for case=%d(iCase). All possible cases:
32443253
}
3245
- for(i=1; i<=7; i++){
3254
+ for(i=1; i<=8; i++){
32463255
@ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
32473256
}
32483257
@ </p>
32493258
@ <p><ol>
32503259
@ <li value='1'> Call fossil_warning()
@@ -3277,10 +3286,16 @@
32773286
}
32783287
@ <li value='7'> call webpage_error()"
32793288
if( iCase==7 ){
32803289
cgi_reset_content();
32813290
webpage_error("Case 7 from /test-warning");
3291
+ }
3292
+ @ <li value='8'> simulated timeout"
3293
+ if( iCase==8 ){
3294
+ fossil_set_timeout(1);
3295
+ cgi_reset_content();
3296
+ sqlite3_sleep(1100);
32823297
}
32833298
@ </ol>
32843299
@ <p>End of test</p>
32853300
style_finish_page();
32863301
}
32873302
--- src/main.c
+++ src/main.c
@@ -143,10 +143,11 @@
143
144 struct Global {
145 int argc; char **argv; /* Command-line arguments to the program */
146 char *nameOfExe; /* Full path of executable. */
147 const char *zErrlog; /* Log errors to this file, if not NULL */
 
148 int isConst; /* True if the output is unchanging & cacheable */
149 const char *zVfsName; /* The VFS to use for database connections */
150 sqlite3 *db; /* The connection to the databases */
151 sqlite3 *dbConfig; /* Separate connection for global_config table */
152 char *zAuxSchema; /* Main repository aux-schema */
@@ -673,10 +674,11 @@
673 int fossil_main(int argc, char **argv){
674 const char *zCmdName = "unknown";
675 const CmdOrPage *pCmd = 0;
676 int rc;
677
 
678 #if !defined(_WIN32_WCE)
679 if( fossil_getenv("FOSSIL_BREAK") ){
680 if( isatty(0) && isatty(2) ){
681 fprintf(stderr,
682 "attach debugger to process %d and press any key to continue.\n",
@@ -957,11 +959,13 @@
957 rc = TH_OK;
958 }
959 if( rc==TH_OK || rc==TH_RETURN || rc==TH_CONTINUE ){
960 if( rc==TH_OK || rc==TH_RETURN ){
961 #endif
 
962 pCmd->xFunc();
 
963 #ifdef FOSSIL_ENABLE_TH1_HOOKS
964 }
965 if( !g.isHTTP && !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
966 Th_CommandNotify(pCmd->zName, pCmd->eCmdFlags);
967 }
@@ -1527,17 +1531,17 @@
1527 size_t i;
1528 Blob out;
1529 size = backtrace(array, sizeof(array)/sizeof(array[0]));
1530 strings = backtrace_symbols(array, size);
1531 blob_init(&out, 0, 0);
1532 blob_appendf(&out, "Segfault");
1533 for(i=0; i<size; i++){
1534 blob_appendf(&out, "\n(%d) %s", i, strings[i]);
1535 }
1536 fossil_panic("%s", blob_str(&out));
1537 #else
1538 fossil_panic("Segfault");
1539 #endif
1540 exit(1);
1541 }
1542
1543 /*
@@ -1548,10 +1552,11 @@
1548 #ifndef _WIN32
1549 if( g.fAnyTrace ){
1550 fprintf(stderr,"/***** sigpipe received by subprocess %d ****\n", getpid());
1551 }
1552 #endif
 
1553 db_panic_close();
1554 exit(1);
1555 }
1556
1557 /*
@@ -1620,10 +1625,11 @@
1620 char *zPath = NULL;
1621 int i;
1622 const CmdOrPage *pCmd = 0;
1623 const char *zBase = g.zRepositoryName;
1624
 
1625 #if !defined(_WIN32)
1626 signal(SIGSEGV, sigsegv_handler);
1627 #endif
1628
1629 /* Handle universal query parameters */
@@ -2022,10 +2028,11 @@
2022 rc = TH_OK;
2023 }
2024 if( rc==TH_OK || rc==TH_RETURN || rc==TH_CONTINUE ){
2025 if( rc==TH_OK || rc==TH_RETURN ){
2026 #endif
 
2027 pCmd->xFunc();
2028 #ifdef FOSSIL_ENABLE_TH1_HOOKS
2029 }
2030 if( !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
2031 Th_WebpageNotify(pCmd->zName+1, pCmd->eCmdFlags);
@@ -2035,10 +2042,11 @@
2035 #endif
2036 }
2037
2038 /* Return the result.
2039 */
 
2040 cgi_reply();
2041 }
2042
2043 /* If the CGI program contains one or more lines of the form
2044 **
@@ -2785,12 +2793,13 @@
2785 #ifndef _WIN32
2786 static int nAlarmSeconds = 0;
2787 static void sigalrm_handler(int x){
2788 sqlite3_uint64 tmUser = 0, tmKernel = 0;
2789 fossil_cpu_times(&tmUser, &tmKernel);
2790 fossil_panic("Timeout after %d seconds - user %,llu µs, sys %,llu µs",
2791 nAlarmSeconds, tmUser, tmKernel);
 
2792 }
2793 #endif
2794
2795 /*
2796 ** Arrange to timeout using SIGALRM after N seconds. Or if N==0, cancel
@@ -3240,11 +3249,11 @@
3240 @ <p>Generate a message to the <a href="%R/errorlog">error log</a>
3241 @ by clicking on one of the following cases:
3242 }else{
3243 @ <p>This is the test page for case=%d(iCase). All possible cases:
3244 }
3245 for(i=1; i<=7; i++){
3246 @ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
3247 }
3248 @ </p>
3249 @ <p><ol>
3250 @ <li value='1'> Call fossil_warning()
@@ -3277,10 +3286,16 @@
3277 }
3278 @ <li value='7'> call webpage_error()"
3279 if( iCase==7 ){
3280 cgi_reset_content();
3281 webpage_error("Case 7 from /test-warning");
 
 
 
 
 
 
3282 }
3283 @ </ol>
3284 @ <p>End of test</p>
3285 style_finish_page();
3286 }
3287
--- src/main.c
+++ src/main.c
@@ -143,10 +143,11 @@
143
144 struct Global {
145 int argc; char **argv; /* Command-line arguments to the program */
146 char *nameOfExe; /* Full path of executable. */
147 const char *zErrlog; /* Log errors to this file, if not NULL */
148 const char *zPhase; /* Phase of operation, for use by the error log */
149 int isConst; /* True if the output is unchanging & cacheable */
150 const char *zVfsName; /* The VFS to use for database connections */
151 sqlite3 *db; /* The connection to the databases */
152 sqlite3 *dbConfig; /* Separate connection for global_config table */
153 char *zAuxSchema; /* Main repository aux-schema */
@@ -673,10 +674,11 @@
674 int fossil_main(int argc, char **argv){
675 const char *zCmdName = "unknown";
676 const CmdOrPage *pCmd = 0;
677 int rc;
678
679 g.zPhase = "init";
680 #if !defined(_WIN32_WCE)
681 if( fossil_getenv("FOSSIL_BREAK") ){
682 if( isatty(0) && isatty(2) ){
683 fprintf(stderr,
684 "attach debugger to process %d and press any key to continue.\n",
@@ -957,11 +959,13 @@
959 rc = TH_OK;
960 }
961 if( rc==TH_OK || rc==TH_RETURN || rc==TH_CONTINUE ){
962 if( rc==TH_OK || rc==TH_RETURN ){
963 #endif
964 g.zPhase = pCmd->zName;
965 pCmd->xFunc();
966 g.zPhase = "shutdown";
967 #ifdef FOSSIL_ENABLE_TH1_HOOKS
968 }
969 if( !g.isHTTP && !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
970 Th_CommandNotify(pCmd->zName, pCmd->eCmdFlags);
971 }
@@ -1527,17 +1531,17 @@
1531 size_t i;
1532 Blob out;
1533 size = backtrace(array, sizeof(array)/sizeof(array[0]));
1534 strings = backtrace_symbols(array, size);
1535 blob_init(&out, 0, 0);
1536 blob_appendf(&out, "Segfault during %s", g.zPhase);
1537 for(i=0; i<size; i++){
1538 blob_appendf(&out, "\n(%d) %s", i, strings[i]);
1539 }
1540 fossil_panic("%s", blob_str(&out));
1541 #else
1542 fossil_panic("Segfault during %s", g.zPhase);
1543 #endif
1544 exit(1);
1545 }
1546
1547 /*
@@ -1548,10 +1552,11 @@
1552 #ifndef _WIN32
1553 if( g.fAnyTrace ){
1554 fprintf(stderr,"/***** sigpipe received by subprocess %d ****\n", getpid());
1555 }
1556 #endif
1557 g.zPhase = "sigpipe shutdown";
1558 db_panic_close();
1559 exit(1);
1560 }
1561
1562 /*
@@ -1620,10 +1625,11 @@
1625 char *zPath = NULL;
1626 int i;
1627 const CmdOrPage *pCmd = 0;
1628 const char *zBase = g.zRepositoryName;
1629
1630 g.zPhase = "process_one_web_page";
1631 #if !defined(_WIN32)
1632 signal(SIGSEGV, sigsegv_handler);
1633 #endif
1634
1635 /* Handle universal query parameters */
@@ -2022,10 +2028,11 @@
2028 rc = TH_OK;
2029 }
2030 if( rc==TH_OK || rc==TH_RETURN || rc==TH_CONTINUE ){
2031 if( rc==TH_OK || rc==TH_RETURN ){
2032 #endif
2033 g.zPhase = pCmd->zName;
2034 pCmd->xFunc();
2035 #ifdef FOSSIL_ENABLE_TH1_HOOKS
2036 }
2037 if( !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
2038 Th_WebpageNotify(pCmd->zName+1, pCmd->eCmdFlags);
@@ -2035,10 +2042,11 @@
2042 #endif
2043 }
2044
2045 /* Return the result.
2046 */
2047 g.zPhase = "web-page reply";
2048 cgi_reply();
2049 }
2050
2051 /* If the CGI program contains one or more lines of the form
2052 **
@@ -2785,12 +2793,13 @@
2793 #ifndef _WIN32
2794 static int nAlarmSeconds = 0;
2795 static void sigalrm_handler(int x){
2796 sqlite3_uint64 tmUser = 0, tmKernel = 0;
2797 fossil_cpu_times(&tmUser, &tmKernel);
2798 fossil_panic("Timeout after %d seconds during %s"
2799 " - user %,llu µs, sys %,llu µs",
2800 nAlarmSeconds, g.zPhase, tmUser, tmKernel);
2801 }
2802 #endif
2803
2804 /*
2805 ** Arrange to timeout using SIGALRM after N seconds. Or if N==0, cancel
@@ -3240,11 +3249,11 @@
3249 @ <p>Generate a message to the <a href="%R/errorlog">error log</a>
3250 @ by clicking on one of the following cases:
3251 }else{
3252 @ <p>This is the test page for case=%d(iCase). All possible cases:
3253 }
3254 for(i=1; i<=8; i++){
3255 @ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
3256 }
3257 @ </p>
3258 @ <p><ol>
3259 @ <li value='1'> Call fossil_warning()
@@ -3277,10 +3286,16 @@
3286 }
3287 @ <li value='7'> call webpage_error()"
3288 if( iCase==7 ){
3289 cgi_reset_content();
3290 webpage_error("Case 7 from /test-warning");
3291 }
3292 @ <li value='8'> simulated timeout"
3293 if( iCase==8 ){
3294 fossil_set_timeout(1);
3295 cgi_reset_content();
3296 sqlite3_sleep(1100);
3297 }
3298 @ </ol>
3299 @ <p>End of test</p>
3300 style_finish_page();
3301 }
3302

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button