The bug disturbed me about two days: when running the code I have a runtime error of "terminate called without an active exception\n Aborted",why?
I try to locate the code and find the line may be exit the code "xx = new int [num]", the num in my test case is about 640000(64MB memory to new). when I set the num much smaller as 10, it is OK, but my code get a wrong answer this time.
I try to delete all the "try/catch" Clause but still have this error.
Also I // all the function which call the "xx = new int [num]" clause, the error still exist, and this time I locate the code may exit is a normal "for loop".
All the case passed the compiler, have u ever met this error in running your code?Thank you!
I // some delete clause and get the error below: * glibc detected * ./ESMF_RegridWeightGen: munmap_chunk(): invalid pointer: 0x00000000005cd376 *
I encountered this when I tried to use throw; outside of a catch clause. The rethrow fails and that error message is displayed.
When I've seen this error, it was caused by the thread object destructing before the thread it encapsulated has exited.
With MinGW, adding the
-mthreads
compiler option to gcc solves this problem.From the gcc manual:
Like Gearoid Murphy said the error happens when the thread object is destructed before the thread function itself has been fully executed. I detected this error using tinythread library (http://tinythreadpp.bitsnbites.eu/):
Before:
After:
The "terminate without an active exception" message is a hint that, at some point in your program, exception handling got broken.
The memory allocation is probably the primary cause, but probably not the error site. The large allocation will throw a std::bad_alloc exception, and this exception is incorrectly handled somewhere.
To validate the theory, insert a line like
above the allocation, this should trigger the bug as well.
I've encountered two common causes for this:
You should be able to diagnose the latter condition with a debugger. A stack trace of your application (e.g. obtained by running it in gdb) should help greatly.