Bug 1951278

Summary: /usr/bin/i686-w64-mingw32-ar -M segfaults sometimes doing the SAVE command
Product: Red Hat Enterprise Linux 9 Reporter: Mohan Boddu <mboddu>
Component: mingw-binutilsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED CURRENTRELEASE QA Contact: rhel8-maint
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: CentOS StreamCC: ailan, bstinson, carl, jen, jwboyer, knoel, nickc, rjones, tzheng, ymankad
Target Milestone: betaKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: mingw-binutils-2.34-9.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-12-07 21:30:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1913743    
Bug Blocks: 1951115    
Attachments:
Description Flags
Proposed patch none

Description Mohan Boddu 2021-04-19 21:23:23 UTC
mingw-crt failed to build from source in Red Hat Enterprise Linux 9 CentOS Stream

https://kojihub.stream.rdu2.redhat.com//koji/taskinfo?taskID=247569


For details on the mass rebuild see:

Please fix mingw-crt at your earliest convenience and set the bug's status to
ASSIGNED when you start fixing it.

Comment 2 Richard W.M. Jones 2021-04-26 13:42:02 UTC
mingw-* packages in RHEL 9 (not 8) are mine.

Comment 3 Richard W.M. Jones 2021-04-26 15:05:29 UTC
This is actually a bug in mingw-binutils.  The 'ar' tool crashes:

(gdb) bt
#0  __GI___fileno (fp=0x0) at fileno.c:35
#1  0x0000000000482e81 in ar_save () at ../../binutils/arsup.c:358
#2  yyparse.isra.0 ()
    at /usr/src/debug/mingw-binutils-2.34-8.el9.x86_64/build_win32/binutils/arparse.y:131
#3  0x0000000000403cdb in mri_emul () at ../../binutils/ar.c:179
#4  main (argc=<optimized out>, argv=<optimized out>)
    at ../../binutils/ar.c:778

Comment 4 Richard W.M. Jones 2021-04-26 15:36:04 UTC
This is caused by the following downstream patch that we added for a CVE:

  Subject: [PATCH] binutils: Make smart_rename safe too

Actually it's not even used in Fedora mingw-binutils.  Since RHEL 9 binutils
has moved to 2.35 (vs mingw-binutils 2.34) I am going to synchronize this
with binutils

Comment 5 Richard W.M. Jones 2021-04-26 15:38:37 UTC
Actually no the bogus patch is also present in RHEL 9 binutils
(binutils-CVE-2021-20197.patch).  I don't think we can fix this
for mingw-binutils until this patch can be fixed.

Comment 6 Nick Clifton 2021-04-26 15:45:54 UTC
I suspect that the problem is also related to:

https://sourceware.org/bugzilla/show_bug.cgi?id=27456

Comment 7 Nick Clifton 2021-04-26 15:52:25 UTC
(In reply to Nick Clifton from comment #6)
Sorry, I meant this PR:

  https://sourceware.org/bugzilla/show_bug.cgi?id=27270

Comment 8 Nick Clifton 2021-04-26 16:11:00 UTC
Created attachment 1775641 [details]
Proposed patch

Hi Rich,

  Are you able to try out this patch and see if it solves the problem ?

Cheers
  Nick

Comment 9 Richard W.M. Jones 2021-04-26 16:19:16 UTC
I can.

Actually I went about it in a different way - I manually fixed up
commit 6184480d7ce1bc on top of mingw-binutils 2.34 and I'm testing
that out at the moment.

Your patch looks really very different though - is it derived from
something else upstream?

Comment 10 Nick Clifton 2021-04-26 16:22:55 UTC
(In reply to Richard W.M. Jones from comment #9)
> I can.
> 
> Actually I went about it in a different way - I manually fixed up
> commit 6184480d7ce1bc on top of mingw-binutils 2.34 and I'm testing
> that out at the moment.
>
> Your patch looks really very different though - is it derived from
> something else upstream?

Yes - it is based on comparing the very latest version of the upstream sources of the files affected (arsup.c, rename.c, etc) with the current c9s sources.  If I remember correctly the fix for 27270 works, but also causes some build problems on Windows machines, and with recent versions of gcc and clang.  Hence I thought that synchronizing might be best.

If your solution works, and presumably is simpler, then lets go with that.  I am all for keeping things simple.

Cheers
  Nick

Comment 11 Richard W.M. Jones 2021-04-26 16:29:16 UTC
Since my fix seems to be OK, I went with that:
https://gitlab.com/redhat/centos-stream/rpms/mingw-binutils/-/merge_requests/1

Comment 12 Jeff Nelson 2021-04-28 21:53:51 UTC
Restore assignee that appears to have been accidentally reset when the component was changed (comment 3).

Comment 13 tingting zheng 2021-06-23 02:23:56 UTC
Checked mingw-crt and mingw-binutils package, both have been built successfully:

mingw-crt-8.0.0-3.el9:https://kojihub.stream.rdu2.redhat.com//koji/buildinfo?buildID=5458.
mingw-binutils-2.34-9.el9:https://kojihub.stream.rdu2.redhat.com//koji/buildinfo?buildID=7285.

Comment 17 tingting zheng 2021-07-29 05:47:58 UTC
The bug has been fixed as mingw-crt and mingw-binutils have been built successfully:

mingw-crt-8.0.0-3.el9:https://kojihub.stream.rdu2.redhat.com//koji/buildinfo?buildID=5458.
mingw-binutils-2.34-9.el9:https://kojihub.stream.rdu2.redhat.com//koji/buildinfo?buildID=7285.