From: Bruce Momjian Date: Mon, 1 Nov 2004 19:21:50 +0000 (+0000) Subject: That's just the lovely way windows handles a "segfault". Gotta be really X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=422971522c35262c9d9e0d2d59bebe4925021f3f;p=users%2Fbernd%2Fpostgres.git That's just the lovely way windows handles a "segfault". Gotta be really interesting for MS to catch all those dumps... Anyway. Oops. Seems I ran my regression tests with the old psql, and just managed to update the backend, when I tested that patch. Turns out there are codepaths where we'd access the Critical Section before it was initialized. Attached patch breaks the initializeation off to a separate part and adds that one to a much earlier position in the program. Magnus Hagander --- diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index d0b1c3f8e1..2097c808e6 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -307,9 +307,14 @@ consoleHandler(DWORD dwCtrlType) } void -setup_cancel_handler(void) +setup_win32_locks(void) { InitializeCriticalSection(&cancelConnLock); +} + +void +setup_cancel_handler(void) +{ SetConsoleCtrlHandler(consoleHandler, TRUE); } diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h index d2ec4bfe96..772739820e 100644 --- a/src/bin/psql/common.h +++ b/src/bin/psql/common.h @@ -49,6 +49,7 @@ extern void ResetCancelConn(void); #ifndef WIN32 extern void handle_sigint(SIGNAL_ARGS); #else +extern void setup_win32_locks(void); extern void setup_cancel_handler(void); #endif diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 6af5d05351..e329336492 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -121,6 +121,7 @@ main(int argc, char *argv[]) #ifdef WIN32 setvbuf(stderr, NULL, _IONBF, 0); + setup_win32_locks(); #endif pset.cur_cmd_source = stdin; pset.cur_cmd_interactive = false;