Bug 15447 - dwp crashes with fseek(NULL) when executable without any .dwo files is specified
Summary: dwp crashes with fseek(NULL) when executable without any .dwo files is specified
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
Depends on:
Reported: 2013-05-09 02:01 UTC by Paul Pluzhnikov
Modified: 2022-11-17 18:20 UTC (History)
3 users (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Paul Pluzhnikov 2013-05-09 02:01:01 UTC
Reported by Peeter Joot:

dwp built from current trunk:

gdb -q --args gold/dwp -o t --exec /bin/date
Reading symbols from /build/gold/dwp...done.
(gdb) r
Starting program: /build/gold/dwp -o t --exec /bin/date

Program received signal SIGSEGV, Segmentation fault.
__GI_fseek (fp=0x0, offset=0, whence=0) at fseek.c:40
40      fseek.c: No such file or directory.
(gdb) bt
#0  __GI_fseek (fp=0x0, offset=0, whence=0) at fseek.c:40
#1  0x0000000000407841 in gold::Dwp_output_file::write_new_section (this=0x7fffffffcfe0, section_name=0x5f3508 ".debug_cu_index", contents=0x8d0710 "\002", len=16, align=8) at ../../src/gold/dwp.cc:1812
#2  0x000000000041f74d in gold::Dwp_output_file::write_index<false> (this=0x7fffffffcfe0, sect_name=0x5f3508 ".debug_cu_index", index=...) at ../../src/gold/dwp.cc:1921
#3  0x0000000000407be5 in gold::Dwp_output_file::finalize (this=0x7fffffffcfe0) at ../../src/gold/dwp.cc:1725
#4  0x0000000000405c02 in main (argc=5, argv=0x7fffffffd418) at ../../src/gold/dwp.cc:2278
Comment 1 trass3r 2020-07-01 13:35:16 UTC
The same crash happens with DWARF5 dwos (-gsplit-dwarf -gdwarf-5).
Comment 2 trass3r 2020-07-08 16:05:27 UTC
diff --git a/gold/dwp.cc b/gold/dwp.cc
index 7c4eef090d..d71caae357 100644
--- a/gold/dwp.cc
+++ b/gold/dwp.cc
@@ -2418,6 +2418,8 @@ main(int argc, char** argv)
       Dwo_file exe_file(exe_filename);
+      if (files.empty())
+        gold_fatal(_("Could not find any dwo links in specified EXE"));

   // Add any additional files listed on command line.
Comment 3 Jordan Williams 2022-11-17 18:20:22 UTC
I only see this crash when attempting to use the DWARF 5 format. DWP seems to be able to find the .dwo files necessary for the DWARF 4 format when given the executable.