Debug Perl Segmentation Fault
Install Devel::Trace.
Run your perl script with tracing enabled:
perl -d:Trace myscript.pl >trace 2>&1
Tail the file to see which Perl lines are executed leading up to the segmentation fault.
user2004469
Updated on June 13, 2022Comments
-
user2004469 almost 2 years
I'm using AcePerl to download data from the wormbase.org database. When I download certain database objects I get (after a certain number of objects) a segmentation fault. This behaviour is reproducible.
I had a look at the core dump and
where
prints a huge stack of function calls:#0 0xb763c0ac in ?? () from /lib/i386-linux-gnu/libc.so.6 #1 0xb763eddc in malloc () from /lib/i386-linux-gnu/libc.so.6 #2 0x080c07ca in Perl_safesysmalloc () #3 0x080f3a02 in Perl_sv_grow () #4 0x080ebe38 in Perl_sv_setsv_flags () #5 0x080ecb76 in Perl_newSVsv () #6 0x0811516f in Perl_save_item () #7 0x080c7dd8 in Perl_get_db_sub () #8 0x080e7a4c in Perl_pp_entersub () #9 0x08075570 in Perl_call_sv () #10 0x080edd25 in Perl_sv_clear () #11 0x080ee3eb in Perl_sv_free2 () #12 0x080d79ec in Perl_hv_free_ent () #13 0x080d7c8c in ?? () #14 0x080db6ff in Perl_hv_undef_flags () #15 0x080edf72 in Perl_sv_clear () #16 0x080ee3eb in Perl_sv_free2 () #17 0x080d79ec in Perl_hv_free_ent () #18 0x080d7c8c in ?? () #19 0x080db6ff in Perl_hv_undef_flags () #20 0x080edf72 in Perl_sv_clear () #21 0x080ee3eb in Perl_sv_free2 () #22 0x080d79ec in Perl_hv_free_ent () #23 0x080d7c8c in ?? () #24 0x080db6ff in Perl_hv_undef_flags () #25 0x080edf72 in Perl_sv_clear () #26 0x080ee3eb in Perl_sv_free2 () #27 0x080d79ec in Perl_hv_free_ent () #28 0x080d7c8c in ?? () #29 0x080db6ff in Perl_hv_undef_flags () #30 0x080edf72 in Perl_sv_clear () #31 0x080ee3eb in Perl_sv_free2 () #32 0x080d79ec in Perl_hv_free_ent () #33 0x080d7c8c in ?? () #34 0x080db6ff in Perl_hv_undef_flags () #35 0x080edf72 in Perl_sv_clear () #36 0x080ee3eb in Perl_sv_free2 () #37 0x080d79ec in Perl_hv_free_ent () #38 0x080d7c8c in ?? () #39 0x080db6ff in Perl_hv_undef_flags () #40 0x080edf72 in Perl_sv_clear () #41 0x080ee3eb in Perl_sv_free2 () #42 0x080d79ec in Perl_hv_free_ent () #43 0x080d7c8c in ?? () #44 0x080db6ff in Perl_hv_undef_flags () #45 0x080edf72 in Perl_sv_clear () #46 0x080ee3eb in Perl_sv_free2 () #47 0x080d79ec in Perl_hv_free_ent () #48 0x080d7c8c in ?? () #49 0x080db6ff in Perl_hv_undef_flags () #50 0x080edf72 in Perl_sv_clear () #51 0x080ee3eb in Perl_sv_free2 () #52 0x080d79ec in Perl_hv_free_ent () #53 0x080d7c8c in ?? () ...
These function calls are repeated thousands of time. I also called
perl -d:Trace myscript.pl > log
but the logfile is about 3 GB large.Is there a more convenient way to debug this script?
EDIT: My script: http://paste.ubuntu.com/5564630/ .
My schema file: http://paste.ubuntu.com/5564631/ . It determines which data to download.
The seg fault is raised after ~2300go_terms
.