Bug 27270 - ar segfaults trying to build virtualbox guest additions
Summary: ar segfaults trying to build virtualbox guest additions
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.36
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: CVE-2021-20197
  Show dependency treegraph
 
Reported: 2021-01-28 16:31 UTC by Heinz Wiesinger
Modified: 2021-02-03 11:06 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed: 2021-01-31 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Heinz Wiesinger 2021-01-28 16:31:59 UTC
I'm trying to build the virtualbox guest additions on Slackware-current (2021-01-26). When trying to link a static lib ar segfaults.

kBuild: Linking RuntimeBldProg
kmk: *** [/tmp/VirtualBox-6.1.18/kBuild/footer-pass2-compiling-targets.kmk:515: /tmp/VirtualBox-6.1.18/out/linux.amd64/release/obj/RuntimeBldProg/RuntimeBldProg.a] Segmentation fault
The failing command:
@kmk_builtin_redirect -rti /tmp/VirtualBox-6.1.18/out/linux.amd64/release/obj/RuntimeBldProg/RuntimeBldProg.a.ar-script -- ar -M

backtrace:

#0  0x00007ffff7ccf980 in fileno_unlocked () from /lib64/libc.so.6
#1  0x0000000000408202 in ar_save () at arsup.c:358
#2  0x0000000000404cd2 in yyparse () at arparse.y:131
#3  0x0000000000403f0f in mri_emul () at ar.c:185
#4  main (argc=<optimized out>, argv=<optimized out>) at ar.c:789

I can reproduce this reliably so in case there's extra information needed please let me know.
Comment 1 Heinz Wiesinger 2021-01-28 16:32:36 UTC
Forgot to mention, with binutils-2.35.1 it builds fine.
Comment 2 Alan Modra 2021-01-31 04:07:41 UTC
See also pr27284
Comment 3 Sourceware Commits 2021-02-03 03:00:57 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=95b91a043aeaeb546d2fea556d84a2de1e917770

commit 95b91a043aeaeb546d2fea556d84a2de1e917770
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Feb 1 02:04:41 2021 +1030

    pr27270 and pr27284, ar segfaults and wrong file mode
    
            PR 27270
            PR 27284
            PR 26945
            * ar.c: Don't include libbfd.h.
            (write_archive): Replace xmalloc+strcpy with xstrdup.  Use
            bfd_stat rather than fstat on iostream.  Move stat and fd tests
            outside of _WIN32 ifdef.  Delete skip_stat variable.
            * arsup.c (temp_name, real_ofd): New static variables.
            (ar_open): Use make_tempname and bfd_fdopenw.
            (ar_save): Adjust to suit ar_open changes.  Move stat output
            of _WIN32 ifdef.
            * objcopy.c: Don't include libbfd.h.
            (copy_file): Use bfd_stat.
Comment 4 Sourceware Commits 2021-02-03 11:05:01 UTC
The binutils-2_36-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6184480d7ce1bcd57669a62867efc68418d0de7c

commit 6184480d7ce1bcd57669a62867efc68418d0de7c
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Feb 1 02:04:41 2021 +1030

    pr27270 and pr27284, ar segfaults and wrong file mode
    
            PR 27270
            PR 27284
            PR 26945
            * ar.c: Don't include libbfd.h.
            (write_archive): Replace xmalloc+strcpy with xstrdup.  Use
            bfd_stat rather than fstat on iostream.  Move stat and fd tests
            outside of _WIN32 ifdef.  Delete skip_stat variable.
            * arsup.c (temp_name, real_ofd): New static variables.
            (ar_open): Use make_tempname and bfd_fdopenw.
            (ar_save): Adjust to suit ar_open changes.  Move stat output
            of _WIN32 ifdef.
            * objcopy.c: Don't include libbfd.h.
            (copy_file): Use bfd_stat.
    
    (cherry picked from commit 95b91a043aeaeb546d2fea556d84a2de1e917770)
Comment 5 Alan Modra 2021-02-03 11:06:35 UTC
Fixed