segfaults

Ellery Newcomer ellery-newcomer at utulsa.edu
Tue Feb 23 06:45:11 PST 2010


On 02/23/2010 06:28 AM, Steven Schveighoffer wrote:
> On Mon, 22 Feb 2010 21:14:08 -0500, Ellery Newcomer
> <ellery-newcomer at utulsa.edu> wrote:
>
>> Is there any decent way to figure out where segfaults are coming from?
>>
>> e.g. 200k lines of bad code converted from java
>>
>> I tried gdb, and it didn't seem to work too well.
>>
>> Die: DW_TAG_type_unit (abbrev 3, offset 0x6d)
>> parent at offset: 0xb
>> has children: FALSE
>> attributes:
>> DW_AT_byte_size (DW_FORM_data1) constant: 8
>> Dwarf Error: Missing children for type unit [in module
>> /home/ellery/dxl.exe]
>> Missing separate debuginfos, use: debuginfo-install glibc-2.11.1-1.i686
>>
>>
>> And I'm not proficient with gdb.
>>
>> dmd 1.056 / tango .99999 or whatever
>>
>> fedora linux
>
> GDB is probably the best option. Have you tried compiling with -gc? I've
> had luck with that in the past.

it gives me

Dwarf Error: Cannot find DIE at 0x0 referenced from DIE at 0x11bd4 [in 
module /home/ellery/dxl.exe]

I'm thinking it's an issue with DMD. I can get backtraces with simple 
programs.

>
> Segfault gives you a signal (SIGSEGV), you could try handling the signal
> to print information about where the program is.
>
> Other than that, you could try logging. Tango has really good logging
> facilities. Try putting logging messages in functions that get called at
> various stages in the program. You can continue to narrow down where the
> failure is by instrumenting even further. Once you determine the
> function it's in, then I usually do something like this after every line:

that's what I've been doing. it's tedious.

>
> Stdout.formatln("here {}", __LINE__);
>
> Of course, Tango's Stdout is thread unsafe, I can't remember the thread
> safe version, something like Trace (if you are using threads).
>
> You should get a line number just before the failed call.
>
> -Steve



More information about the Digitalmars-d-learn mailing list