https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121554

            Bug ID: 121554
           Summary: cobol3005883.cob FAILs with UBSAN (parse.y:13145:26:
                    runtime error: load of value 4294967295, which is not
                    a valid value for type 'cbl_division_t')
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: testsuite-fail
          Severity: normal
          Priority: P3
         Component: cobol
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
            Blocks: 63426
  Target Milestone: ---

```
$ export
ASAN_OPTIONS="detect_leaks=0:halt_on_error=1:abort_on_error=1:print_summary=1"
$ export
UBSAN_OPTIONS="halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1"
$ make check-cobol
```

>From cobol.log:
```
Executing on host: /home/sam/bugs/gcc-bld2/gcc/testsuite/cobol/../../gcobol
-B/home/sam/bugs/gcc-bld2/gcc/testsuite/cobol/../../  cobol3005883.cob   
-fdiagnostics-plain-output  -fdiagnostics-plain-output 
-Wno-complain-wrong-lang -S -o cobol3005883.s    (timeout = 300)
spawn -ignore SIGHUP /home/sam/bugs/gcc-bld2/gcc/testsuite/cobol/../../gcobol
-B/home/sam/bugs/gcc-bld2/gcc/testsuite/cobol/../../ cobol3005883.cob
-fdiagnostics-plain-output -fdiagnostics-plain-output -Wno-complain-wrong-lang
-S -o cobol3005883.s
/home/sam/git/gcc/gcc/cobol/parse.y:13145:26: runtime error: load of value
4294967295, which is not a valid value for type 'cbl_division_t'
    #0 0x0000004215d5 in mode_syntax_only()
/home/sam/git/gcc/gcc/cobol/parse.y:13145
    #1 0x000000c4d977 in parser_enter_file(char const*)
/home/sam/git/gcc/gcc/cobol/genapi.cc:3685
    #2 0x000001281959 in parse_file /home/sam/git/gcc/gcc/cobol/util.cc:2401
    #3 0x000001281959 in cobol_parse_files(int, char const**)
/home/sam/git/gcc/gcc/cobol/util.cc:2466
    #4 0x000003eeab1e in compile_file /home/sam/git/gcc/gcc/toplev.cc:453
    #5 0x00000080f882 in do_compile /home/sam/git/gcc/gcc/toplev.cc:2222
    #6 0x00000080f882 in toplev::main(int, char**)
/home/sam/git/gcc/gcc/toplev.cc:2385
    #7 0x000000818a63 in main /home/sam/git/gcc/gcc/main.cc:39
    #8 0x7fcc870036c6 in __libc_start_call_main (/usr/lib64/libc.so.6+0x36c6)
(BuildId: b64414070d772a19314121b7b298566622573bfa)
    #9 0x7fcc87003775 in __libc_start_main (/usr/lib64/libc.so.6+0x3775)
(BuildId: b64414070d772a19314121b7b298566622573bfa)
    #10 0x00000081aab0 in _start (/home/sam/bugs/gcc-bld2/gcc/cobol1+0x81aab0)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/home/sam/git/gcc/gcc/cobol/parse.y:13145:26
cobol1: internal compiler error: Aborted
0xc3f06a0 internal_error(char const*, ...)
        /home/sam/git/gcc/gcc/diagnostic-global-context.cc:534
0x3ee781f crash_signal
        /home/sam/git/gcc/gcc/toplev.cc:323
0x401f58 __sanitizer::Abort()
       
/home/sam/git/gcc/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp:163
0x93520b __sanitizer::Die()
       
/home/sam/git/gcc/libsanitizer/sanitizer_common/sanitizer_termination.cpp:58
0xcb4d8b9 __ubsan::ScopedReport::~ScopedReport()
        /home/sam/git/gcc/libsanitizer/ubsan/ubsan_diag.cpp:402
0xcb4809a handleLoadInvalidValue
        /home/sam/git/gcc/libsanitizer/ubsan/ubsan_handlers.cpp:540
0xcb4c4ae __ubsan_handle_load_invalid_value
        /home/sam/git/gcc/libsanitizer/ubsan/ubsan_handlers.cpp:545
0x4215d5 mode_syntax_only()
        /home/sam/git/gcc/gcc/cobol/parse.y:13145
0xc4d977 parser_enter_file(char const*)
        /home/sam/git/gcc/gcc/cobol/genapi.cc:3685
0x1281959 parse_file
        /home/sam/git/gcc/gcc/cobol/util.cc:2401
0x1281959 cobol_parse_files(int, char const**)
        /home/sam/git/gcc/gcc/cobol/util.cc:2466
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

```
$ ./xgcc -v
Using built-in specs.
COLLECT_GCC=./xgcc
Target: x86_64-pc-linux-gnu
Configured with: /home/sam/git/gcc/configure --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --disable-multilib
--disable-werror --enable-languages=cobol,c,c++
--prefix=/home/sam/bugs/gcc-pfx2 --enable-checking=release --with-libatomic
--with-libbacktrace --without-system-zlib --enable-lto
--with-build-config='bootstrap-asan bootstrap-ubsan'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.0 20250814 (experimental) (GCC)
```


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426
[Bug 63426] [meta-bug] Issues found with -fsanitize=undefined

Reply via email to