SIGTRAP when freeing memory Programming Software Development by Zcool31 … when I try to delete the arrays, I get a SIGTRAP error (on windows using MinGW). This is a problem as… the arrays: [CODE]Game::~Game(){ free(velx); //this line gives SIGTRAP free(vely); //changing the order doesn't matter free(velx0… Re: SIGTRAP when freeing memory Programming Software Development by Zcool31 … statement in the destructor is the one that causes the SIGTRAP. If I move them around, it doesn't matter. Whichever… one is first is the one that will give SIGTRAP. This is all part of an open source game I… Re: SIGTRAP when freeing memory Programming Software Development by Ketsuekiame … to do.[/quote] Which could be the cause of the SIGTRAP. I realise that it is "safe" to do… to delete the null pointer and hence flagging up the SIGTRAP. EDIT: Clarifying my reasoning for saying he could have a… Re: SIGTRAP when freeing memory Programming Software Development by Ketsuekiame …. [code] if(velx) delete [] velx; [/code] If this stops the SIGTRAP then the problem lies somewhere else in your code because… Re: SIGTRAP when freeing memory Programming Software Development by Aranarth First off, using delete on a null pointer never throws and is perfectly okay. A SIGTRAP can indicate memory corruption or a double free. Remember that the memory corruption does not necessarily need to occur in Flob.cpp. You also should consequently use new and delete/delete[] in your programs to avoid any problems. Re: SIGTRAP when freeing memory Programming Software Development by Ketsuekiame … a null pointer never throws and is perfectly okay. A SIGTRAP can indicate memory corruption or a double free. Remember that… Re: SIGTRAP when freeing memory Programming Software Development by Zcool31 … not the problem that I'm having. The problem is SIGTRAP. It happens when I delete a particular set of arrays… Re: SIGTRAP when freeing memory Programming Software Development by Zcool31 …. Though I really would expect a SIGSEGV instead of a SIGTRAP. Re: SIGTRAP when freeing memory Programming Software Development by ctaylo21 What is the class (NoClass?) at the bottom of your post for? And not to be picky but this is the C++ forum and you're posting C code :) Re: SIGTRAP when freeing memory Programming Software Development by NathanOliver have you tried to use the new and delete function instead of C functions? [code=c++] float * velx = new float[size]; // later on delete [] velx; velx = 0; //or velx = NULL; [/code] Re: SIGTRAP when freeing memory Programming Software Development by ctaylo21 I realized it was your signature after I posted my comment, sorry about that, long day at work :( Ketsuekiame is correct, trying to delete a NULL pointer will cause an exception, I know it has caused me a few headaches in the past. Hopefully that solves your problem. Re: SIGTRAP when freeing memory Programming Software Development by NathanOliver Actually deleting a null pointer or one that has been set to zero is perfectly safe. Trying to delete a pointer again before setting it to null or 0 is not safe. Here is a link to the MSDN page I'm using for my argument. [url]http://msdn.microsoft.com/en-us/library/h6227113%28VS.80%29.aspx[/url] Re: SIGTRAP when freeing memory Programming Software Development by Ketsuekiame [QUOTE=NathanOliver;1224147]Actually deleting a null pointer or one that has been set to zero is perfectly safe. Trying to delete a pointer again before setting it to null or 0 is not safe. Here is a link to the MSDN page I'm using for my argument. [url]http://msdn.microsoft.com/en-us/library/h6227113%28VS.80%29.aspx[/url][/QUOTE] Although… Re: SIGTRAP when freeing memory Programming Software Development by NathanOliver Deleting a null pointer will throw an exception but it is safe to do. I was able to call delete on null pointers back when I had MSVC++ 6.0. here is a little piece of the c++98 standard. This is from 3.7.3.2 paragraph 3 The value of the first parameter supplied to a deallocation function shall be a null pointer value, or refer to storage … Re: SIGTRAP when freeing memory Programming Software Development by NathanOliver Yes that would. He said he had a operator precedence problem that he fixed and it works now. Re: SIGTRAP when freeing memory Programming Software Development by Ketsuekiame Well if it wasn't posted in the thread how was I supposed to know... :P Re: SIGTRAP when freeing memory Programming Software Development by Zcool31 I never mentioned anything about operator precedence or it being fixed. The fact is that the issue is still present. What's strange is that it's only those arrays. Elsewhere in my code I'm able to create and delete arrays (even delete NULL pointers) without a single problem. I've gone over every line that accesses these arrays with a fine comb. … Re: SIGTRAP when freeing memory Programming Software Development by Aranarth [QUOTE=Ketsuekiame]I swear it used to do. Attempting to delete a null pointer caused me no end of issues through university so I always ended up null checking the pointer first. This may have been a quirk of MSVC though.[/QUOTE] I suppose that's possible. I assume this was before the first C++ standard was released? Nevertheless, it should no … Re: SIGTRAP when freeing memory Programming Software Development by Ketsuekiame [QUOTE=Aranarth;1226092]I suppose that's possible. I assume this was before the first C++ standard was released? Nevertheless, it should no longer be done, as delete does nothing when the pointer is 0. An additional check is redundant.[/QUOTE] No idea but Microsoft has never been one to conform to standards, just look at IE! *whistles … Re: SIGTRAP when freeing memory Programming Software Development by Zcool31 I went back to the C++ style new/delete statements. Of course, this changed absolutely nothing at all. Here's my new destructor. I put in a few simple test statements just to make sure. When I delete any array of floats, it works. But when I delete the arrays for my game, I get SIGSEGV. Here's the code: [CODE]Flob::~Flob(){ //delete null … Re: SIGTRAP when freeing memory Programming Software Development by Ketsuekiame [quote="Wikipedia"]On POSIX-compliant platforms, SIGSEGV is the signal sent to a process when it makes an invalid memory reference, or segmentation fault.[/quote] [URL="http://en.wikipedia.org/wiki/SIGSEGV"]Link[/URL] Based on the above, are you sure your pointer is valid at that point? has it been deleted before hand but … Re: SIGTRAP when freeing memory Programming Software Development by NathanOliver Sorry about saying it was a operator precedence thing. I had this thread confused with another one. Re: SIGTRAP when freeing memory Programming Software Development by NathanOliver Where do you use the Flob class? if you are making copies of objects that might be your problem since you don have a copy constructor defined. What would happen if you add a copy constructor to your Flob class? Re: SIGTRAP when freeing memory Programming Software Development by Zcool31 Sorry for the bump. I'd really like to get this fixed. Re: SIGTRAP when freeing memory Programming Software Development by NathanOliver I saw your private copy constructor in Flob.h but I do not see it defined in Flob.cpp so that might be why. If it is defined somewhere let me know so i can take a look. It might not be the copy constructor but better to make sure it isn't it right? Perl's DESTROY and Signal Handling Programming Software Development by muppetjones … you Ctrl-C the program. I tried using [INLINECODE]use sigtrap qw(handler DESTROY INT QUIT);[/INLINECODE], but I'm not… SDL - SigSegV fault Programming Software Development by Labdabeta …. Also sometimes instead of a SigSegV fault I get a SigTrap fault. Here is the code involved with the SigSegV. SDLGame… Re: how do I kill a script after a set amount of time? Programming Software Development by jim mcnamara If the box in question a unix box, try setting up a signal handler - with use sigtrap alarm() is supposed to send a SIGALRM to the process, which by default terminates. Unless another handler (trap statement) is active This does not work in Windows. Re: C++ Please Help Killed by signal 8(SIGFPE). Programming Software Development by Clinton Portis … */ #define SIGILL 4 /* illegal instruction (not reset when caught) */ #define SIGTRAP 5 /* trace trap (not reset when caught) */ #define SIGABRT 6… Re: Code::Blocks is not debugging Programming Software Development by Labdabeta … debugging symbols found) (no debugging symbols found) Program received signal SIGTRAP, Trace/breakpoint trap. In ntdll!DbgUiConnectToDbg () (C:\WINDOWS\system32\ntdll…