From: Bernd Becker Newsgroups: comp.os.msdos.djgpp Subject: freeing/allocating memory causes a SIGSEGV Date: Wed, 23 Aug 2000 01:23:15 +0100 Organization: (Posted via) INKA e.V. http://www.inka.de/ Lines: 40 Message-ID: NNTP-Posting-Host: ccclxviii.yapay.inka.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sapa.inka.de 966986664 5457 212.227.15.242 (22 Aug 2000 23:24:24 GMT) X-Complaints-To: newsmaster AT inka DOT de NNTP-Posting-Date: 22 Aug 2000 23:24:24 GMT X-Newsreader: Forte Agent 1.8/32.548 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com When memory is allocated/freed in a loop the program will crash after going through it for a while with a SIGSEGV. Examples of this: a. the imploding() function in the gstring class (originally for linux but can be used for DOS after editing the makefiles). builtin_vec_delete calls free()as causes a SIGSEGV at free+172. b. the read_line() function in the CFG 1.2 library (.ini-style file reading/writing). When in a line starting with the comment sign '#' a ';' (an other comment sign) is encountered directly behind a letter __dj_movedata()+37 will cause a SIGSEGV. The maintainer says it only causes the letter before the ';' to be garbled under Linux which he uses. c. in a loop with lots of set_cfg_????() functions, a SIGSEGV will be caused at free+17 in the approximate middle of the second loop. Again in the CFG 1.2 library. No problems for the maintainer of the library. Another thing I found out after using Fortify with a program of mine is that memory for classes, list entries, etc. is allocated just fine, but when trying to free it with delete, according to Fortify nothing happens. And even though I didn't change the code in a way that should affect it, it crashed afterwards with SIGSEGVs today when exiting the program and the deconstructor tries to delete the entries of the gui and event lists as well as the gui objects themselves. After commenting out the delete line in the remove_entry routines it crashed with a SIGSEGV in the routine containing the loops where the deconstructors are called. This didn't happen before it just went back to DOS cleanly !! I'm using DJGPP 2.03, GCC/GPP 2.95.2, and Binutils 2.10 under DOS 6.22 with 128MB RAM. I don't expect anyone telling me what may cause these SIGSEGVs - I'm completely clueless for one - but if somebody could try the gstring class's implode() function and tell me if it worked for him, it would help some; I can send the archive, if necessary. TIA, Bernd