PDA

View Full Version : Segmentation Fault when Program Starts



KaptainKarl
4th September 2009, 16:29
I am attempting to develop QT console APP for RHEL 5 using QT 4.5.2.
I can build and run a simple app one system, but when I attempt to run the same app on a different RHEL 5 machine the program produces a Segmentation Fault.

I eventually created two small programs to demonstrate the error. The first program runs with no problems. The second creates the segmentation fault.
Here is the code for program one (which works):


#include <stdio.h>
int main()
{
fprintf(stderr, "Program running.\n");
return 0;
}

Here is the code from program two (produces segmentation fault):


#include <QDebug>
int main()
{
qDebug("Program running.");
return 0;
}

Here is the programs running on the non-development machine:

# ./QTTest
Program running.
# ./QTTest2
Segmentation fault

I configured QT 4.5.2 with -static -release options.

I would appreciate any advice or help.

Karl

wysota
5th September 2009, 02:04
Run the application under a debugger and paste here the backtrace after the crash.

KaptainKarl
8th September 2009, 13:37
The system where the program will not run is on another continent, therefore I must rely on someone else to perform experiments. I was able to recompile the QT program with the -g FLAG set and send a new version. The end user returned the following:


# ldd -r QTTest2
ldd: exited with unknown exit code (139)


# gdb QTTest3
GNU gdb Red Hat Linux (6.5-16.el5rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"..."/usr/local/tmp/QTTest3": not in executable format: File format not recognized

NOTE: QTTest3 is the same source as QTTest2. The only change is that the -g CFLAG was set in the Makefile and the target name was changed.

I have attempted sending the executable that works on the local system several times and with several methods (email, FTP, Skype).

Karl

victor.fernandez
9th September 2009, 08:30
Do not set the -g flag manually in the makefile, since the makefile is automatically generated by qmake and it will be overwritten the next time you run qmake. Add "CONFIG += debug" in the project file instead or run qmake with the -debug parameter.

wysota
9th September 2009, 09:11
Are you sure the application is compiled for the right architecture? Where was the application compiled and how?

KaptainKarl
9th September 2009, 15:00
Both applications are compiled on an i686 machine running RHEL 5.
The target system is also an i686 machine running RHEL5.

Here is the output of uname -a for both systems:

Development system:

Linux <hostname removed> 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686 i686 i386 GNU/Linux

Target system:

Linux <hostname removed> 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686 i686 i386 GNU/Linux

Karl

wysota
9th September 2009, 16:28
What does "file QTTest3" return and what does "file /bin/bash" return?

lyuts
10th September 2009, 08:43
1. What version of Qt is on you r target machine?
2. Turn the core dumping on using ulimit or limit(depending on your shell). When your program fails investigate that core dump.