This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: 1008 segfaults in genattr


> I'd prefer either a fixed atexit, or if we can stick in code to the

Where "fixed" matches whose definition of undefined behaviour? :-)

> testcase to detect infinite looping, if that is the problem, and call
> abort (or _exit in that case).

Well, that's exactly what atexit() does.  It detects looping and calls
abort.  Linux will do (presumably "did", since H.J. published the patch)
the infinite loop thing that's explictly tested for in this code.  The
exit() that does OpenServer (actually, all the SCO UNIX releases and
maybe the XENIX ones) in is the _successful_ exit.   Change that one
to _exit() and your test case works fine in our case.

> The reason is that the compiler uses atexit internally by itself to
> implement C++ semantics, and if it doesn't work well enough, the
> semantics it presents to the user will be flawed (in my opinion).

Right.   Relying on undefined behaviour when that is performed behind
the back of the user is a tough thing to swallow.

> // prms-id: 9732
> 
> int count;
> int bail = 0;
> 
> struct base {
>   base () { ++count; }
>   ~base () { --count; }
>   base(const base&o) { ++count; }
> };
> 
> class D {
> public:
>   ~D() {
>     if (bail++)
>       {
> 	// On some Linux boxes, we run the dtor for d twice,
> 	// once before exit, and once after!
> 	abort ();
>       }
>     else
>       {
> 	if (count != 0)
> 	  abort ();
> 	exit (0);

        ^^^ Make this exit() and _exit() and you've got yourself a deal.
Actually, I think this is what we agreed to earlier and the patch I 
submitted earlier, isn't it?


RJL


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]