ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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)
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.
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 }
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.