From: Delong Newsgroups: comp.os.msdos.djgpp Subject: One of my segments, suddenly not valid? Date: Sun, 16 Feb 1997 18:04:15 -0500 Organization: ... Lines: 57 Message-ID: <3307926D.E8B@osha.igs.net> Reply-To: dandelong AT osha DOT igs DOT net NNTP-Posting-Host: ttya13.osha.igs.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Sorry about the length of this message ... I seem to be coming across seg violations when accessing the same memory that I allocated earlier. By allocating memory I mean creating a new object (class) that I have declared. I made some output routines that wrote the addresses my program was using for these objects, such as the objects address, the address held to by its 'char *name' parameter, and the value at this 'name' pointer. When I accessed the memory at this 'name' pointer (it often happens during a 'strlen(object->name)' delcaration, but also when I call one of the objects functions like object->paint()). The parent object has these 'objects' added to it and it has a list of pointers, and the value of each object pointer and the pointers (char *name) within the object are the same as when I allocated the new object but when I try to access the memory at any pointer in the object (call a function, access 'char *' member) later on in the program I get a SIGSEGV error and the usual CPU dump. I am using this as my startup params: int _crt0_startup_flags = _CRT0_FLAG_NEARPTR | _CRT0_FLAG_NONMOVE_SBRK; Is this really a problem with segments somehow becoming invalid without my deallocating anything? I'd greatly appreciate it if anyone could offer a suggestion as to what's going on here, I don't have a clue why the same address produces a segviolation. Here are the two output files, the first was taken as the objects were added to the program and the second was taken when they were about to draw themselves (since the object->paint() function was causing a segviolation at first). Output file as list items were created for each directory found 'list.op' address=0x65880 | name=0x65898 *name=. | cname=ListItem address=0x65900 | name=0x65918 *name=.. | cname=ListItem address=0x11dd084 | name=0x11dd09c *name=MAKEPIB | cname=ListItem address=0x11dd204 | name=0x11dd21c *name=FNT | cname=ListItem address=0x11dd2c4 | name=0x11dd2dc *name=IMG | cname=ListItem address=0x11dd344 | name=0x11dd35c *name=MAKEPFN | cname=ListItem address=0x11dd444 | name=0x11dd45c *name=TEST | cname=ListItem address=0x11dd5c4 | name=0x11dd5dc *name=PCX2PIB | cname=ListItem The second output file, the object pointers before painting (the break at '*name=' is the point at which the segv occurred, before it could write the value) 'output' address=0x65880 | name=0x65898 *name=. | cname=ListItem address=0x65900 | name=0x65918 *name=.. | cname=ListItem address=0x11dd084 | name=0x11dd09c *name= Thanks, -- ... Andrew Delong ______________________________________________________________ Check out my hompage ... Great for graphics & DOS programming http://www.osha.igs.net/~dandelong/nash.htm