When I add std::runtime_error("err") expression into my code, I got segmentation fault at address 0 (before entering to main). If instead I use std::exception(), app runs fine.
How std::runtime_error() causes segfault and how to fix it? Thanks!
Code: Select all
#include <stdexcept>
#include <exception>
#include "irrlicht.h"
using namespace irr;
int main() {
IrrlichtDevice* device = createDevice();
if (!device)
throw std::runtime_error("err"); //without this run fine
}
Code: Select all
g++ -ggdb -Wall -Wextra -std=c++11 -o main main2.cc \
-lIrrlicht -lGL -lXxf86vm -lXext -lX11 -lXcursor
Code: Select all
(gdb) bt full
#0 0x00000000 in ?? ()
No symbol table info available.
#1 0xb5d88fe1 in init () at dlerror.c:177
No locals.
#2 0xb5d8942e in _dlerror_run (operate=operate@entry=0xb5d88e10 <dlsym_doit>, args=args@entry=0xbffff160) at dlerror.c:129
result = <optimized out>
#3 0xb5d88e98 in __dlsym (handle=0x0, name=0xb7f8afe5 "posix_memalign") at dlsym.c:70
args = {handle = 0x0, name = 0xb7f8afe5 "posix_memalign", who = 0xb7f674bc, sym = 0xb5d65b20}
result = <optimized out>
#4 0xb7f674bc in ?? () from /usr/lib/nvidia- 304/libGL.so.1
No symbol table info available.
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Code: Select all
LD_DEBUG=all LD_DEBUG_OUTPUT=log.txt ./main
tail log.txt.*
3848: symbol=__pthread_key_create; lookup in file=/lib/i386-linux-gnu/libgcc_s.so.1 [0]
3848: symbol=__pthread_key_create; lookup in file=/lib/i386-linux-gnu/libc.so.6 [0]
3848: symbol=__pthread_key_create; lookup in file=/usr/lib/nvidia-304/tls/libnvidia-tls.so.304.131 [0]
3848: symbol=__pthread_key_create; lookup in file=/usr/lib/nvidia-304/libnvidia-glcore.so.304.131 [0]
3848: symbol=__pthread_key_create; lookup in file=/usr/lib/i386-linux-gnu/libXext.so.6 [0]
3848: symbol=__pthread_key_create; lookup in file=/lib/i386-linux-gnu/libdl.so.2 [0]
3848: symbol=__pthread_key_create; lookup in file=/usr/lib/i386-linux-gnu/libxcb.so.1 [0]
3848: symbol=__pthread_key_create; lookup in file=/lib/ld-linux.so.2 [0]
3848: symbol=__pthread_key_create; lookup in file=/usr/lib/i386-linux-gnu/libXau.so.6 [0]
3848: symbol=__pthread_key_create; lookup in file=/usr/lib/i386-linux-gnu/libXdmcp.so.6 [0]