bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

endless mutual recursion in done() and tryclose()


From: Marco Franzen
Subject: endless mutual recursion in done() and tryclose()
Date: Thu, 19 Oct 2000 14:03:31 +0100

If I run Bison version 1.28 (on HP-UX, compiled with gcc-2.95.2)
where e.g. the output file exists but has no write permission, then bison
eventually dies from a SIGSEGV due to (attempted) endless recursion.

Analysis.

When main is nearly finished, it calls done(0), which calls tryclose()
before it tries to open the output file. If tryopen fails, it recursively
calls done() with the files already closed but the global variables
indicating they are not. Therefore, the first call to tryclose() in done()
fails in the attempt to close an already closed file, leading to further
nested calls to done().

On HP-UX, that looks like this (from the 3rd call to perror)
#0  0x7af6b4c4 in ?? () from /usr/lib/libc.1
#1  0x88f0 in tryclose (ptr=0x2060) at files.c:400
#2  0x8968 in done (k=2) at files.c:409
#3  0x88f8 in tryclose (ptr=0x2060) at files.c:401
#4  0x8968 in done (k=2) at files.c:409
#5  0x8868 in tryopen (name=0x7b03a02d "parse.c", 
    mode=0x6ad2ba6 <Address 0x6ad2ba6 out of bounds>) at files.c:383
#6  0x89cc in done (k=0) at files.c:422
#7  0xc428 in main (argc=6, argv=0x7b03a3a4) at main.c:113
#8  0x7af2bd0c in ?? () from /usr/lib/libc.1

The problem is the global variables (faction, et. al.). If global variables
must be used and also recursion must be used, then those variables should
be set to NULL after (successfully or not) closing the FILE stream to
prevent endless recursion.  (Function tryclose() could do that if it were
changed to receive a FILE**.)

Marco
-----------------------------------------------------------------
This email is confidential and intended solely for the use of the
individual to whom it is addressed.
Any views or opinions presented are solely those of the author
and do not necessarily represent those of Thyron Limited.
If you are not the intended recipient then please be advised
that you have received this email in error and that any use,
dissemination, forwarding, printing or copying of this email
is strictly prohibited.
If you have received this email in error, please notify the
Thyron IT Administrator on +44 (0)1923 236 050 or
send an email to address@hidden
Thank You



reply via email to

[Prev in Thread] Current Thread [Next in Thread]