digitalmars.D - Mysterious segfault
- teqDruid (formerly DemmeGod) (12/12) Jul 10 2004 In what cases would a program segfault whenever trying to access a metho...
- Ben Hinkle (4/19) Jul 10 2004 http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnex...
- teqDruid (30/53) Jul 10 2004 The output from the sample class I've linked to is:
- Ben Hinkle (8/68) Jul 10 2004 #_D3com11neuralnexus10libnnstore6diskIO14nnDiskDatabase10createNodeFC3co...
- teqDruid (5/74) Jul 10 2004 I added these two lines:
- Ben Hinkle (10/86) Jul 10 2004 I meant try replacing writef with printf. The stack looks like it is in ...
- teqDruid (4/18) Jul 10 2004 That did the trick. So how should I use writef?
- Ben Hinkle (7/26) Jul 10 2004 I tried to reproduce the seg-v with a simpler example to see where the b...
- teqDruid (9/41) Jul 10 2004 dmd -Ibuild -Idui/src -unittest -g -debug -d
- Ben Hinkle (16/47) Jul 10 2004 ok, I found some simple reproduction steps (on Linux):
In what cases would a program segfault whenever trying to access a method of a class? I'm aware of that behavior if the reference to the class is null, but other than that, I'm not sure why it would occur. This feels like a stupid error, but I'm not seeing it. I'm using DMD 0.95 in Linux The offending class can be found here: http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/diskIO.d and sample code to access it here: http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/createdb.d I'd appriciate any advice here... I'm pretty stumped. Thanks John
Jul 10 2004
teqDruid (formerly DemmeGod) wrote:In what cases would a program segfault whenever trying to access a method of a class? I'm aware of that behavior if the reference to the class is null, but other than that, I'm not sure why it would occur. This feels like a stupid error, but I'm not seeing it. I'm using DMD 0.95 in Linux The offending class can be found here:http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/diskIO.dand sample code to access it here:http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/createdb.dI'd appriciate any advice here... I'm pretty stumped. Thanks Johncan you run it in gdb and see where it seg-v's?
Jul 10 2004
The output from the sample class I've linked to is: $ ./createdb Starting creation... Database opened 2 So it doesn't even run the debug output that's the first line of the function it's calling. gdb says: ----------------- (gdb) run Starting program: /home/teqdruid/workspace/nnStore/createdb Starting creation... Database opened 2 Program received signal SIGSEGV, Segmentation fault. 0x0804c987 in _D3com11neuralnexus10libnnstore6diskIO14nnDiskDatabase10createNodeFC3com11neuralnexus10libnnstore6nnNode8nnNodeIDZC3com11neuralnexus10libnnstore11nnSt reNode11nnStoreNode () (gdb) bt reNode11nnStoreNode () Previous frame identical to this frame (corrupt stack?) (gdb) ------------------------ I'm not sure what other information in gdb is useful, since I'm not too familiar with the tool. Thanks John On Sat, 10 Jul 2004 09:12:04 -0400, Ben Hinkle wrote:teqDruid (formerly DemmeGod) wrote:In what cases would a program segfault whenever trying to access a method of a class? I'm aware of that behavior if the reference to the class is null, but other than that, I'm not sure why it would occur. This feels like a stupid error, but I'm not seeing it. I'm using DMD 0.95 in Linux The offending class can be found here:http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/diskIO.dand sample code to access it here:http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/createdb.dI'd appriciate any advice here... I'm pretty stumped. Thanks Johncan you run it in gdb and see where it seg-v's?
Jul 10 2004
teqDruid wrote:The output from the sample class I've linked to is: $ ./createdb Starting creation... Database opened 2 So it doesn't even run the debug output that's the first line of the function it's calling. gdb says: ----------------- (gdb) run Starting program: /home/teqdruid/workspace/nnStore/createdb Starting creation... Database opened 2 Program received signal SIGSEGV, Segmentation fault. 0x0804c987 in_D3com11neuralnexus10libnnstore6diskIO14nnDiskDatabase10createNodeFC3com11neuralnexus10libnnstore6nnNode8nnNodeIDZC3com11neuralnexus10libnnstore11nnStoreNode11nnStoreNode() (gdb) btPrevious frame identical to this frame (corrupt stack?) (gdb) ------------------------ I'm not sure what other information in gdb is useful, since I'm not too familiar with the tool. Thanks John On Sat, 10 Jul 2004 09:12:04 -0400, Ben Hinkle wrote:http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/diskIO.dteqDruid (formerly DemmeGod) wrote:In what cases would a program segfault whenever trying to access a method of a class? I'm aware of that behavior if the reference to the class is null, but other than that, I'm not sure why it would occur. This feels like a stupid error, but I'm not seeing it. I'm using DMD 0.95 in Linux The offending class can be found here:http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/createdb.dand sample code to access it here:crazy idea: I notice you are importing both std.stream and std.stdio - could it be the wrong stdout is being used? Does it do the same thing with printf instead of writef?I'd appriciate any advice here... I'm pretty stumped. Thanks Johncan you run it in gdb and see where it seg-v's?
Jul 10 2004
I added these two lines: alias std.stdio.writef writef; alias std.stdio.writefln writefln; To no avail. On Sat, 10 Jul 2004 16:40:36 -0400, Ben Hinkle wrote:teqDruid wrote:The output from the sample class I've linked to is: $ ./createdb Starting creation... Database opened 2 So it doesn't even run the debug output that's the first line of the function it's calling. gdb says: ----------------- (gdb) run Starting program: /home/teqdruid/workspace/nnStore/createdb Starting creation... Database opened 2 Program received signal SIGSEGV, Segmentation fault. 0x0804c987 in_D3com11neuralnexus10libnnstore6diskIO14nnDiskDatabase10createNodeFC3com11neuralnexus10libnnstore6nnNode8nnNodeIDZC3com11neuralnexus10libnnstore11nnStoreNode11nnStoreNode() (gdb) btPrevious frame identical to this frame (corrupt stack?) (gdb) ------------------------ I'm not sure what other information in gdb is useful, since I'm not too familiar with the tool. Thanks John On Sat, 10 Jul 2004 09:12:04 -0400, Ben Hinkle wrote:http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/diskIO.dteqDruid (formerly DemmeGod) wrote:In what cases would a program segfault whenever trying to access a method of a class? I'm aware of that behavior if the reference to the class is null, but other than that, I'm not sure why it would occur. This feels like a stupid error, but I'm not seeing it. I'm using DMD 0.95 in Linux The offending class can be found here:http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/createdb.dand sample code to access it here:crazy idea: I notice you are importing both std.stream and std.stdio - could it be the wrong stdout is being used? Does it do the same thing with printf instead of writef?I'd appriciate any advice here... I'm pretty stumped. Thanks Johncan you run it in gdb and see where it seg-v's?
Jul 10 2004
teqDruid wrote:I added these two lines: alias std.stdio.writef writef; alias std.stdio.writefln writefln; To no avail.I meant try replacing writef with printf. The stack looks like it is in the right function but since that first writefln didn't print anything it must have messed up at the writefln somehow. It isn't a problem of flushing buffers since the newline in writefln would have flushed stdout if the writefln worked.On Sat, 10 Jul 2004 16:40:36 -0400, Ben Hinkle wrote:_D3com11neuralnexus10libnnstore6diskIO14nnDiskDatabase10createNodeFC3com11neuralnexus10libnnstore6nnNode8nnNodeIDZC3com11neuralnexus10libnnstore11nnStoreNode11nnStoreNodeteqDruid wrote:The output from the sample class I've linked to is: $ ./createdb Starting creation... Database opened 2 So it doesn't even run the debug output that's the first line of the function it's calling. gdb says: ----------------- (gdb) run Starting program: /home/teqdruid/workspace/nnStore/createdb Starting creation... Database opened 2 Program received signal SIGSEGV, Segmentation fault. 0x0804c987 in() (gdb) bthttp://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/diskIO.dPrevious frame identical to this frame (corrupt stack?) (gdb) ------------------------ I'm not sure what other information in gdb is useful, since I'm not too familiar with the tool. Thanks John On Sat, 10 Jul 2004 09:12:04 -0400, Ben Hinkle wrote:teqDruid (formerly DemmeGod) wrote:In what cases would a program segfault whenever trying to access a method of a class? I'm aware of that behavior if the reference to the class is null, but other than that, I'm not sure why it would occur. This feels like a stupid error, but I'm not seeing it. I'm using DMD 0.95 in Linux The offending class can be found here:http://www.neuralnexus.com/projects/nnStore/file/trunk/src/com/neuralnexus/libnnstore/createdb.dand sample code to access it here:crazy idea: I notice you are importing both std.stream and std.stdio - could it be the wrong stdout is being used? Does it do the same thing with printf instead of writef?I'd appriciate any advice here... I'm pretty stumped. Thanks Johncan you run it in gdb and see where it seg-v's?
Jul 10 2004
That did the trick. So how should I use writef? Thanks for the help John On Sat, 10 Jul 2004 18:58:50 -0400, Ben Hinkle wrote:teqDruid wrote:I added these two lines: alias std.stdio.writef writef; alias std.stdio.writefln writefln; To no avail.I meant try replacing writef with printf. The stack looks like it is in the right function but since that first writefln didn't print anything it must have messed up at the writefln somehow. It isn't a problem of flushing buffers since the newline in writefln would have flushed stdout if the writefln worked.
Jul 10 2004
teqDruid wrote:That did the trick. So how should I use writef?I tried to reproduce the seg-v with a simpler example to see where the bug is exactly but could get it seg-v. How did you compile those files? From what I understand your code should have worked fine.Thanks for the helpnp - if there's a bug with writef it would be nice to narrow it down to report to Walter.John On Sat, 10 Jul 2004 18:58:50 -0400, Ben Hinkle wrote:teqDruid wrote:I added these two lines: alias std.stdio.writef writef; alias std.stdio.writefln writefln; To no avail.I meant try replacing writef with printf. The stack looks like it is in the right function but since that first writefln didn't print anything it must have messed up at the writefln somehow. It isn't a problem of flushing buffers since the newline in writefln would have flushed stdout if the writefln worked.
Jul 10 2004
dmd -Ibuild -Idui/src -unittest -g -debug -d If you've got a copy of Subversion and Scons: $svn co http://svn.neuralnexus.com/nnStore nnStore $cd nnStore $scons createdb or #scons test John On Sat, 10 Jul 2004 21:55:34 -0400, Ben Hinkle wrote:teqDruid wrote:That did the trick. So how should I use writef?I tried to reproduce the seg-v with a simpler example to see where the bug is exactly but could get it seg-v. How did you compile those files? From what I understand your code should have worked fine.Thanks for the helpnp - if there's a bug with writef it would be nice to narrow it down to report to Walter.John On Sat, 10 Jul 2004 18:58:50 -0400, Ben Hinkle wrote:teqDruid wrote:I added these two lines: alias std.stdio.writef writef; alias std.stdio.writefln writefln; To no avail.I meant try replacing writef with printf. The stack looks like it is in the right function but since that first writefln didn't print anything it must have messed up at the writefln somehow. It isn't a problem of flushing buffers since the newline in writefln would have flushed stdout if the writefln worked.
Jul 10 2004
ok, I found some simple reproduction steps (on Linux): file1.d: import std.stdio; void foo() { writefln("foo"); } file2.d: import file1; import std.stdio; int main() { writefln("before foo"); foo(); return 0; } dmd file1.d file2.d run file1 Both the writefln's are needed. If either are removed it works fine. Ben Hinkle wrote:teqDruid wrote:That did the trick. So how should I use writef?I tried to reproduce the seg-v with a simpler example to see where the bug is exactly but could get it seg-v. How did you compile those files? From what I understand your code should have worked fine.Thanks for the helpnp - if there's a bug with writef it would be nice to narrow it down to report to Walter.John On Sat, 10 Jul 2004 18:58:50 -0400, Ben Hinkle wrote:teqDruid wrote:I added these two lines: alias std.stdio.writef writef; alias std.stdio.writefln writefln; To no avail.I meant try replacing writef with printf. The stack looks like it is in the right function but since that first writefln didn't print anything it must have messed up at the writefln somehow. It isn't a problem of flushing buffers since the newline in writefln would have flushed stdout if the writefln worked.
Jul 10 2004