LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Cannot run program. (https://www.linuxquestions.org/questions/programming-9/cannot-run-program-946045/)

ssunlinux 05-20-2012 03:55 PM

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.

Nominal Animal 05-20-2012 04:57 PM

Quote:

Originally Posted by ssunlinux (Post 4683431)
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.

ssunlinux 05-21-2012 10:48 AM

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 }

Nominal Animal 05-21-2012 05:03 PM

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).


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