J
Jing Cheng
Hi,
I'm using ifstream reading data from a file, as following:
ifstream finput("track.dat");
if(finput.fail()){
cerr << "Open input DATA file error!\n";
exit(-1);
}
int ntrial = 0;
while(finput >> turns){
if(turns < 1) continue;
finput >> x >> xp >> z >> zp;
......
}
finput.close();
but I met a segment fault(core dumped),
then I use gdb to trace the core:
lyyang@walnut ~/research $ gdb lcsimp core
GNU gdb 6.0
Copyright 2003 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 "i686-pc-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".
Core was generated by `./lcsimp'.
Program terminated with signal 11, Segmentation fault.
warning: current_sos: Can't read pathname for load map: Input/output error
Reading symbols from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5...done.
Loaded symbols for /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libgcc_s.so.1...done.
Loaded symbols for /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0 0xb7e379e3 in free () from /lib/libc.so.6
(gdb) backtrace
#0 0xb7e379e3 in free () from /lib/libc.so.6
#1 0xb7fad8e7 in operator delete(void*) () from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5
#2 0xb7fad939 in operator delete[](void*) () from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5
#6 0x080496f0 in main () at lcsimp.cpp:158
(gdb)
Here the 158th line is the end of my main().
What's the problem ?
my data file track.dat is only one line, here is the hexdump, no special
characters:
lyyang@walnut ~/research $ hexdump -C track.dat
00 31 30 30 20 2e 30 32 36 33 20 30 2e 30 20 30 2e |100 .0263 0.0 0.|
10 30 34 32 35 20 30 2e 30 |0425 0.0|
018
Any help would be apreciated. Thanks!
Lingyun
I'm using ifstream reading data from a file, as following:
ifstream finput("track.dat");
if(finput.fail()){
cerr << "Open input DATA file error!\n";
exit(-1);
}
int ntrial = 0;
while(finput >> turns){
if(turns < 1) continue;
finput >> x >> xp >> z >> zp;
......
}
finput.close();
but I met a segment fault(core dumped),
then I use gdb to trace the core:
lyyang@walnut ~/research $ gdb lcsimp core
GNU gdb 6.0
Copyright 2003 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 "i686-pc-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".
Core was generated by `./lcsimp'.
Program terminated with signal 11, Segmentation fault.
warning: current_sos: Can't read pathname for load map: Input/output error
Reading symbols from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5...done.
Loaded symbols for /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libgcc_s.so.1...done.
Loaded symbols for /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0 0xb7e379e3 in free () from /lib/libc.so.6
(gdb) backtrace
#0 0xb7e379e3 in free () from /lib/libc.so.6
#1 0xb7fad8e7 in operator delete(void*) () from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5
#2 0xb7fad939 in operator delete[](void*) () from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5
from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5#3 0xb7f576b7 in std::basic_filebuf said:::_M_destroy_internal_buffer() ()
from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5#4 0xb7f575c1 in std::basic_filebuf said:::close() ()
from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/libstdc++.so.5#5 0xb7f5a746 in std::basic_ifstream said:::close() ()
#6 0x080496f0 in main () at lcsimp.cpp:158
(gdb)
Here the 158th line is the end of my main().
What's the problem ?
my data file track.dat is only one line, here is the hexdump, no special
characters:
lyyang@walnut ~/research $ hexdump -C track.dat
00 31 30 30 20 2e 30 32 36 33 20 30 2e 30 20 30 2e |100 .0263 0.0 0.|
10 30 34 32 35 20 30 2e 30 |0425 0.0|
018
Any help would be apreciated. Thanks!
Lingyun