In article <[EMAIL PROTECTED]>, Matthew Reimer <[EMAIL PROTECTED]> wrote: > We've been having problems with mysql segfaulting. It seems to occur > when it tries to return from a function, so maybe the stack is getting > stomped. Sergey Osokin recently reported a very similar problem on a different threaded C++ program. See message ID <[EMAIL PROTECTED]> in the -hackers archives -- it contains a small test case. I spent a few hours looking at it last weekend, but I wasn't able to solve the problem. The failure occurs in a function like this: void SS::run() { string s; // !!! string s1; // !!! sleep(1); } Upon returning from the function, the destructors for s1 and s get called, in that order. The first one seems to corrupt the stack or a register somehow, such that the code leading up to the call of the second destructor dereferences a garbage pointer. In Sergey's case, merely re-ordering two declarations in a different function makes the problem appear or disappear: void SS::spawn() { #ifdef BAD int rc; Guard guard(m1); // !!! #else Guard guard(m1); // !!! int rc; #endif According to Sergey, the problem arose in -stable some time around 12 November 2000. Sergey has been doing some further investigation to narrow down the changes that caused the problem. I haven't had time to digest his findings yet, and due to work pressures I may not find time soon. In any case, this appears to be a genuine bug that we (FreeBSD) introduced. John -- John Polstra [EMAIL PROTECTED] John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Ch�gyam Trungpa To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-stable" in the body of the message
