Bug 84637 - gcc/dbxout.c:684:14: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself
Summary: gcc/dbxout.c:684:14: runtime error: negation of -9223372036854775808 cannot b...
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 8.0.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Blocks: ubsan
  Show dependency treegraph
Reported: 2018-03-01 07:57 UTC by Martin Liška
Modified: 2018-04-17 22:21 UTC (History)
2 users (show)

See Also:
Target: x86_64-*-*, i?86-*-*
Known to work:
Known to fail:
Last reconfirmed:

gcc8-pr84637.patch (423 bytes, patch)
2018-04-17 14:27 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2018-03-01 07:57:40 UTC
UBSAN boostrap compiler sees:

$  UBSAN_OPTIONS="print_stacktrace=1" ./xgcc -B.  /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/debug/trivial.c -c -gstabs -fno-diagnostics-show-caret -fdiagnostics-color=never -gstabs -S -o trivial.S
../../gcc/dbxout.c:684:14: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself
    #0 0xd673a5 in stabstr_D ../../gcc/dbxout.c:684
    #1 0xd73400 in dbxout_range_type ../../gcc/dbxout.c:1745
    #2 0xd6eba8 in dbxout_type ../../gcc/dbxout.c:2042
    #3 0xd75c43 in dbxout_symbol(tree_node*, int) ../../gcc/dbxout.c:2865
    #4 0xd783b2 in dbxout_init ../../gcc/dbxout.c:1079
    #5 0x74faa0 in lang_dependent_init ../../gcc/toplev.c:1920
    #6 0x74faa0 in do_compile ../../gcc/toplev.c:2118
    #7 0x74faa0 in toplev::main(int, char**) ../../gcc/toplev.c:2267
    #8 0x751cba in main ../../gcc/main.c:39
    #9 0x7fb2075a06e4 in __libc_start_main (/lib64/libc.so.6+0x206e4)
    #10 0x751de8 in _start (/home/marxin/Programming/gcc/objdir/gcc/cc1+0x751de8)
Comment 1 Jim Wilson 2018-03-01 20:49:52 UTC
The stabs support is obsolete and unmaintained.  The best solution is to disable the stabs support for the compiler target you are trying to build.  If you disable the stabs support for your target, the testsuite will stop running stabs tests, and you won't see these errors anymore.

The stabs support can be disabled by removing the dbxelf.h reference in config.sub for x86 linux (and optionally other x86 targets), or by undeffing DBX_DEBUGGING_INFO somewhere in the config/i386 dir.
Comment 2 Martin Liška 2018-04-17 10:55:34 UTC
Thanks for explanation. Do you plan to remove it in the future from GCC or will you leave it there unmaintained?
Comment 3 Jakub Jelinek 2018-04-17 14:27:15 UTC
Created attachment 43963 [details]

I think in this case the fix is rather obvious (though, untested so far and not proposing it for GCC8).
Comment 4 Jakub Jelinek 2018-04-17 22:19:19 UTC
Author: jakub
Date: Tue Apr 17 22:18:47 2018
New Revision: 259451

URL: https://gcc.gnu.org/viewcvs?rev=259451&root=gcc&view=rev
	PR debug/84637
	* dbxout.c (dbxout_int): Perform negation in unsigned int type.
	(stabstr_D): Change type of unum from unsigned int to
	unsigned HOST_WIDE_INT.  Perform negation in unsigned HOST_WIDE_INT

Comment 5 Jakub Jelinek 2018-04-17 22:21:43 UTC