Bug 26554 - SIGSEGV in pe_dll_generate_implib
Summary: SIGSEGV in pe_dll_generate_implib
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.36
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-30 17:27 UTC by Markus Böck
Modified: 2020-09-16 14:10 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Proposed patch (339 bytes, patch)
2020-09-16 12:56 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Böck 2020-08-30 17:27:42 UTC
Current HEAD of the repository (42afa120eb180bce52c692939cd179e3c02160d9) causes a segmentation fault when --out-implib is specified on the command line. The simplest reproduction is to take any C source file that has eg. an empty main in it and compile it with the command:

gcc main.c -Wl,--out-implib,libout.dll.a

with a gcc that targets a MinGW target.

The SIGSEGV is caused by the dll_filename variable being NULL at the call to xstrdup in pe-dll.c:2823

The backtrace generated by gdb is:
#0  0x00007ff9e320d2f1 in strlen () from C:\WINDOWS\System32\msvcrt.dll
#1  0x00000000005600c7 in xstrdup (s=0x0) at ../../libiberty/xstrdup.c:33
#2  0x000000000043f41c in pep_dll_generate_implib (def=0x60148d0, impfilename=0x1797c0 "libcmTC_3e257.dll.a", info=0x6158e0 <link_info>) at ../../ld/pe-dll.c:2823
#3  0x0000000000430984 in gld_i386pep_finish () at ei386pep.c:1775
#4  0x0000000000425cda in ldemul_finish () at ../../ld/ldemul.c:101
#5  0x000000000041ae46 in lang_process () at ../../ld/ldlang.c:8185
#6  0x000000000041f4d8 in main (argc=71, argv=0x1725a0) at ../../ld/ldmain.c:494
#7  0x0000000000401434 in __tmainCRTStartup () at ../crt/crtexe.c:335
#8  0x000000000040113d in mainCRTStartup () at ../crt/crtexe.c:219
Comment 1 Nick Clifton 2020-09-16 12:56:02 UTC
Created attachment 12845 [details]
Proposed patch

Hi Markus,

  I am unable to reproduce this problem. :-(

  Please could you check and see if it still exists with the latest binutils sources.  If it does, please could you try out this patch and let me know if it works.  I have a feeling that although it might stop the seg-fault, it will not fix the underlying problem...

Cheers
  Nick
Comment 2 Markus Böck 2020-09-16 14:10:35 UTC
Yes this problem seems to have been fixed thank you. pep_dll_generate_implib doesn't get called anymore on trunk therefore not causing a segfault (revision 337882d477675296a22fd8c1f7412ca30c70d9b0).