PDA

View Full Version : linux "Segmentation fault"



harrison
2nd March 2010, 09:09
i built my program on ubuntu with qt creator successfully, and then i ran it failed by given the output "Segmentation fault".

now i can do nothing, anybody can be nice to tell me why?

JD2000
2nd March 2010, 09:42
Segmentation faults happen when a programme tries to access memory outside of that allocated to it.

The result of such a fault is 'undefined' which generally means a crash of some description.

They are normally caused by rogue pointers, over-running array bounds etc.

axeljaeger
2nd March 2010, 22:06
Start your programm using a debugger, wait for the crash, invoke the "backtrace" function of the debugger and post the output here.

harrison
3rd March 2010, 01:47
thank you
so far I know why I was told "Segmentation fault",
I just comment some "can not run" code which tie my hands and then I totally forgot :(
now I uncomment those code, the red compile output come to me again

../build/debug/libMarkerDB.so: undefined reference to `void IndexerWrapper::write<QByteArray>(short, QByteArray const&) const'
../build/debug/libMarkerDB.so: undefined reference to `void IndexerWrapper::write<short>(short, short const&) const'
make: Leaving directory `/home/pad/Source/4.8.0_marker/branches/Marker_Refact/Marker'
../build/debug/libMarkerDB.so: undefined reference to `void IndexerWrapper::write<QString>(short, QString const&) const'
collect2: ld returned 1 exit status
make: *** [../build/debug/Marker] Error 1
Exited with code 2.
Error while building project Marker
When executing build step 'Make'

due to the output above, I checked the file defined that template function.
and I am sure that header file was included well.

the template function was defined just like :

template <typename T>
void IndexerWrapper::write(short code, const T &value) const {}

maybe I express myself not so clearly , my English is not so good
hope all those message is enough for you to give me some tips...thanks

harrison
3rd March 2010, 08:57
so strange
I moved that function definition from source file to header file, it built normally.
but when it ran, "Segmentation fault" came again..
I did as axeljaeger said, got things as follow:

warning: (Internal error: pc 0x46e1a1 in read in psymtab, but not in symtab.)


Program received signal SIGSEGV, Segmentation fault.
0x02ac3f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) backtrace
#0 0x02ac3f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0x02c684ff in XSetCommand () from /usr/lib/libX11.so.6
#2 0x02c6cf51 in XSetWMProperties () from /usr/lib/libX11.so.6
#3 0x06d73134 in QWidgetPrivate::create_sys (this=0x83782d0, window=0, initializeWindow=true, destroyOldWindow=true)
at /var/tmp/qt-src/src/gui/kernel/qwidget_x11.cpp:795
#4 0x06d2bb21 in QWidget::create (this=0xbffff1ec, window=0, initializeWindow=true, destroyOldWindow=true)
at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:1319
#5 0x06d2e7b1 in QWidget::setVisible (this=0xbffff1ec, visible=true) at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:7353
#6 0x081730f0 in QWidget::show (this=0xbffff1ec) at /usr/local/qt-4.6.2/qt/include/QtGui/qwidget.h:485
#7 0x00bc827d in PadSystem::PadSplashScreen::show (this=0xbffff1ec) at src/PadSplashScreen.cpp:58
#8 0x08223a46 in main (argc=1, argv=0xbffff304) at main.cpp:66
(gdb)

JD2000
3rd March 2010, 09:33
The error seems to be generated by a strlen() call.

Is the argument a proper ctype null terminated string?