Getting “ArrayIndexOutOfBoundsException: null” with NO stack trace

String concatenated with a null reference might get you such a message: Object obj = null; throw new ArrayIndexOutOfBoundsException(“” + obj); If you’re using an Oracle JVM you may want to add -XX:-OmitStackTraceInFastThrow as an additional parameter to see if it helps. For some basic exceptions, the JVM reuses the same exception instance after a … Read more

Can one use libSegFault.so to get backtraces for SIGABRT?

env SEGFAULT_SIGNALS=”abrt segv” LD_PRELOAD=/lib/libSegFault.so someapp Note that the actual path to the preload library may differ. On my machine, I’d use env SEGFAULT_SIGNALS=”abrt segv” LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so some-64bit-app or env SEGFAULT_SIGNALS=”abrt segv” LD_PRELOAD=/lib/i386-linux-gnu/libSegFault.so some-32bit-app depending whether the application I was running was compiled 64-bit or 32-bit. (You can use file to check.) The source tells us there … Read more

How to throw exception without resetting stack trace?

With .NET Framework 4.5 there is now an ExceptionDispatchInfo which supports this exact scenario. It allows capturing a complete exception and rethrowing it from somewhere else without overwriting the contained stack trace. code sample due to request in comment using System.Runtime.ExceptionServices; class Test { private ExceptionDispatchInfo _exInfo; public void DeleteNoThrow(string path) { try { File.Delete(path); … Read more

c++ stack trace from unhandled exception? [duplicate]

Edited Answer: You can use std::set_terminate #include <cstdlib> #include <iostream> #include <stdexcept> #include <execinfo.h> void handler() { void *trace_elems[20]; int trace_elem_count(backtrace( trace_elems, 20 )); char **stack_syms(backtrace_symbols( trace_elems, trace_elem_count )); for ( int i = 0 ; i < trace_elem_count ; ++i ) { std::cout << stack_syms[i] << “\n”; } free( stack_syms ); exit(1); } int … Read more

tech