home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sgi
- Path: sparky!uunet!uunet.ca!geac!snitor!sni.ca!ash
- From: ash@sni.ca (Ashwin Palekar)
- Subject: Possible bug in c-compiler ?
- Message-ID: <1992Aug14.165251.20524@sni.ca>
- Sender: ash@iron.sni.ca (Ashwin Palekar)
- Nntp-Posting-Host: iron.sni.ca
- Organization: Siemens Nixdorf, Sietec Open Systems, Toronto, Canada
- Date: Fri, 14 Aug 1992 16:52:51 GMT
- Lines: 62
-
- ON: IRIX 4.0.1 11150233 IP12
-
- Problem Description:
- ~~~~~~~~~~~~~~~~~~~~
- The software works with debug version (default compiler option)
- and dumps core in optimised version (-O).
-
- Problem Analysis :
- ~~~~~~~~~~~~~~~~~
- the code has the following logic.
- {
- struct xyz *variable=NULL;
- setjmp();
-
- variable = ... allocate memory.
- free (variable)
- variable = NULL;
-
- longjmp(Go to statement shown next)
-
- if variable != NULL free(variable)
-
- }
-
- In debug mode "variable" is equal to NULL after longjmp.
- In optimised mode "variable" it is not NULL after longjmp tries to free it
- resulting in core dump.
-
- IMP: This same behaviour is noticed on mips platform (maybe because of
- same compiler).
-
- Temporary Solution:
- ~~~~~~~~~~~~~~~~~~~
- If I make the variable declaration static it works in both cases.
-
- Possible explaination:
- ~~~~~~~~~~~~~~~~~~~~~
-
- setjmp may not store registers , and if during optimization the
- structure is made register variable then it will result in choas.
-
- Background:
- ~~~~~~~~~~
- The software works on lots of other platforms (with same source code).
- I checked for memory leaks before the function starts , none that i could
- find.
-
-
- Other inputs:
- ~~~~~~~~~~~~~~~~~~~~~
- The software uses 'setjmp' and 'longjmp' extensively and many cases do work
- fine.
-
- --
- ---------------------------------------------------------------------------
- Ashwin Palekar : ash@sni.ca
- Office:
- Tel : (416) 496-8510
- Fax : (416) 496-8524
- Siemens Nixdorf Information Systems Ltd.,
- 2235 Sheppard Ave. East, Suite 1800, Willowdale , Ontario , Canada M2J 3B5.
- ---------------------------------------------------------------------------
-