LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-20-2012, 03:55 PM   #1
ssunlinux
LQ Newbie
 
Registered: Nov 2011
Posts: 5
Blog Entries: 1

Rep: Reputation: Disabled
Cannot run program.


I have a program can run normally previous, but can not run now.
I did not change the code, so the code is correct.
here is the out put information when i run the code.

$ gdb scooppic
GNU gdb (GDB) Fedora (7.3.50.20110722-13.fc16)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/ssun/Documents/Mark/sphere/init/scooppic/scooppic...done.
(gdb) r exp001a sexp001a
Starting program: /home/ssun/Documents/Mark/sphere/init/scooppic/scooppic exp001a sexp001a
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Open Scoop File: sexp001a
Open soil File: exp001a
Read Scoop: 0
Zmax: 0.038360
Read soil: 0 6
SCF: 1.000000
CEN: 0.049123 0.054283 0.016597
POS: 0.049123 0.054283 0.016597
Read Ini Done

Program received signal SIGSEGV, Segmentation fault.
0x00bc4010 in time@plt () from /lib/libexpat.so.1
______________________
$ ./scooppic exp001a sexp001a
Open Scoop File: sexp001a
Open soil File: exp001a
Read Scoop: 0
Zmax: 0.038360
Read soil: 0 6
SCF: 1.000000
CEN: 0.049123 0.054283 0.016597
POS: 0.049123 0.054283 0.016597
Read Ini Done
Segmentation fault (core dumped)

Do you have any idea? I am using Fedora 16.
 
Old 05-20-2012, 04:57 PM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by ssunlinux View Post
I have a program can run normally previous, but can not run now.
I did not change the code, so the code is correct.
That is no proof that the code is correct! A program that dies with SIGSEGV must have a bug in it (or in one of the libraries it uses).

It is likely that the code happened to work with a certain library version, and you have updated your libraries (most likely, expat library, as part of system updates) to a version which no longer masks the bug.
 
Old 05-21-2012, 10:48 AM   #3
ssunlinux
LQ Newbie
 
Registered: Nov 2011
Posts: 5

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Thank you Nominal!
I agree with you. so I try to find the bug in my program. but still have trouble.
I use valgrind run the program, here is the output:
valgrind ./scooppic
valgrind: mmap(0x804f000, 1408000000) failed in UME with error 22 (Invalid argument).
valgrind: this can be caused by executables with very large text, data or bss segments.

it seems the program cannot run under valgrind.

I use gdb run the program step by step the program is stop at the file '/usr/src/debug/freeglut-2.6.0/src/freeglut_window.c' and the screen output is list below:
gdb scooppic
GNU gdb (GDB) Fedora (7.3.50.20110722-13.fc16)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/ssun/Documents/Mark/sphere/init/scooppic/scooppic...done.
(gdb) r exp001a sexp001a
Starting program: /home/ssun/Documents/Mark/sphere/init/scooppic/scooppic exp001a sexp001a
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Open Scoop File: sexp001a
Open soil File: exp001a
Read Scoop: 0
Zmax: 0.038360
Read soil: 0 6
SCF: 1.000000
CEN: 0.049123 0.054283 0.016597
POS: 0.049123 0.054283 0.016597
Read Ini Done

Program received signal SIGSEGV, Segmentation fault.
0x00bc4010 in time@plt () from /lib/libexpat.so.1
(gdb) b scooppic.c :96
Breakpoint 1 at 0x8049aac: file scooppic.c, line 96.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/ssun/Documents/Mark/sphere/init/scooppic/scooppic exp001a sexp001a
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Open Scoop File: sexp001a
Open soil File: exp001a
Read Scoop: 0
Zmax: 0.038360
Read soil: 0 6
SCF: 1.000000
CEN: 0.049123 0.054283 0.016597
POS: 0.049123 0.054283 0.016597
Read Ini Done

Breakpoint 1, main (argc=3, argv=0xbffff2a4) at scooppic.c:96
96 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
(gdb) n
97 glutCreateWindow(windowname);
(gdb) s
glutCreateWindow (title=0x804e3a0 "exp001a") at freeglut_window.c:1174
1174 {
(gdb) n
1181 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateWindow" );
(gdb)
1183 return fgCreateWindow( NULL, title, fgState.Position.Use,
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x00bc4010 in time@plt () from /lib/libexpat.so.1
(gdb) l
1178 * XXX Steve Baker, 12/16/04, 4:22 PM CST, "Re: [Freeglut-developer]
1179 * XXX Desired 'freeglut' behaviour when there is no current window"
1180 */
1181 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateWindow" );
1182
1183 return fgCreateWindow( NULL, title, fgState.Position.Use,
1184 fgState.Position.X, fgState.Position.Y,
1185 fgState.Size.Use, fgState.Size.X, fgState.Size.Y,
1186 GL_FALSE, GL_FALSE )->ID;
1187 }
 
Old 05-21-2012, 05:03 PM   #4
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Ah ha, so it crashes in the Freeglut fgCreateWindow() function. Freeglut is an open source implementation of the OpenGL Utility Toolkit.

Have you updated your graphics drivers recently? Do
Code:
glxinfo
glxgears
run without crashing? Their output or functionality is not interesting, but if they don't run or crash, it means there is something wonky with your graphics drivers, and that the same crash happens in your application. In that case, the most likely culprit is actually the graphics drivers, not the program itself.

If you have recently installed proprietary graphics drivers, they tend to overwrite the OpenGL libraries; perhaps the overwritten libraries are incompatible with[FONT=Monospace] freeglut[/FONT}? It's not like Nvidia or ATI/AMD really care about us Linux users.

I recommend you reinstall the freeglut library next. If that does not help, you could try an older version of freeglut (but only if you are using proprietary graphics drivers -- the logic being that those graphics drivers might be compatible with an older version of freeglut).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help Trying to open or run a file/program through a c++ program xskycamefalling Programming 4 01-19-2010 02:26 PM
Need help Trying to open or run a file/program through a c++ program xskycamefalling Programming 2 01-18-2010 02:51 PM
Simple C++ Program: Program Compiles But Won't Run (Segmentation Fault) violagirl23 Programming 3 01-09-2008 12:09 AM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 08:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration