Bug 26418 - UBSAN error: bfd/cache.c:386:12:
Summary: UBSAN error: bfd/cache.c:386:12:
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: 2.36
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-20 12:05 UTC by Martin Liska
Modified: 2020-08-28 13:46 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-08-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liska 2020-08-20 12:05:24 UTC
The following fails when I build binutils with:
configure --build=x86_64-linux --disable-nls --disable-gdb --disable-gdbserver --disable-sim --disable-readline --disable-libdecnumber --enable-obsolete --target=alpha-linuxecoff CFLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" CXXLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" LDFLAGS="-ldl"
Target: alpha-linuxecoff
| 	exit( YY_EXIT_FAILURE );
Executing on host: sh -c {/dev/shm/z4gjobiy/ld/../gas/as-new   -I/home/mliska/Programming/binutils/ld/testsuite/ld-checks   -o tmpdir/asm.o /home/mliska/Programming/binutils/ld/testsuite/ld-checks/asm.s 2>&1}  /dev/null ld.tmp (timeout = 300)
/home/mliska/Programming/binutils/bfd/cache.c:386:12: runtime error: null pointer passed as argument 1, which is declared to never be null
Comment 1 Sourceware Commits 2020-08-26 13:54:31 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 9863cbb7bd3495107a5b1b4d887c95d859c9a35e
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Aug 26 14:18:53 2020 +0930

    PR26418 UBSAN: cache.c:386 null pointer fwrite
    
            PR 26418
            * ecofflink.c (WRITE): Don't write size 0 chunks.
Comment 2 Alan Modra 2020-08-26 14:37:03 UTC
Fixed
Comment 3 Sourceware Commits 2020-08-28 12:30:03 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 7ca371dba5d612ff1cdaa4ffe33474c1993fbe7f
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Aug 28 21:45:49 2020 +0930

    PR26418 UBSAN: cache.c:386 null pointer fwrite
    
    The previous "fix" tested the wrong value.
    
            PR 26418
            * ecofflink.c (WRITE): Really don't write zero size chunks.
Comment 4 Sourceware Commits 2020-08-28 13:46:16 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 07319accdf8eecc5111b343802dadd067f683d26
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Aug 28 23:06:47 2020 +0930

    PR26418 UBSAN: cache.c:386 null pointer fwrite
    
    And some more.
    
            PR 26418
            * ecofflink.c (bfd_ecoff_write_accumulated_debug): Don't write
            zero size buffers.