[Bug 295431] CURRENT compiler miscompiles lang/mit-scheme

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 20 May 2026 12:17:00 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295431

Dimitry Andric <dim@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dim@FreeBSD.org

--- Comment #1 from Dimitry Andric <dim@FreeBSD.org> ---
The first thing I tried is building the port with CFLAGS=-fsanitize=undefined
LDFLAGS=-fsanitize=undefined, and that gives quite a few interesting results:

echo '(generate-shim "blowfish" "#include \"blowfish-shim.h\"")' \
    | ../run-build --batch-mode
obstack.c:68:17: runtime error: member access within null pointer of type
'struct fooalign'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior obstack.c:68:17
obstack.c:91:22: runtime error: call to function obstack_chunk_alloc through
pointer to incorrect function type 'struct _obstack_chunk *(*)(long)'
(/wrkdirs/share/dim/ports/lang/mit-scheme/work/mit-scheme-12.1/src/microcode/scheme+0x473c88):
note: obstack_chunk_alloc defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior obstack.c:91:22
option.c:408:45: runtime error: applying non-zero offset 59388727439880 to null
pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior option.c:408:45
option.c:654:31: runtime error: applying non-zero offset 59388727439392 to null
pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior option.c:654:31
option.c:714:19: runtime error: applying non-zero offset 59388727439472 to null
pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior option.c:714:19
wind.c:84:12: runtime error: applying non-zero offset 59388727447616 to null
pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior wind.c:84:12
cmpintmd.c:206:11: runtime error: load of misaligned address 0x360386afc8ca for
type 'insn_t *' (aka 'unsigned char *'), which requires 8 byte alignment
0x360386afc8ca: note: pointer points here
 00 68  48 b9 70 d8 a5 01 00 00  00 00 e9 99 0f 05 00 00  00 00 00 00 00 00 00
00  03 00 00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior cmpintmd.c:206:11
cmpintmd.c:222:3: runtime error: store to misaligned address 0x360386afc8ca for
type 'insn_t *' (aka 'unsigned char *'), which requires 8 byte alignment
0x360386afc8ca: note: pointer points here
 00 68  48 b9 70 d8 a5 01 00 00  00 00 e9 99 0f 05 00 00  00 00 00 00 00 00 00
00  03 00 00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior cmpintmd.c:222:3
cmpintmd.c:235:4: runtime error: store to misaligned address 0x360386afc8d3 for
type 'int32_t' (aka 'int'), which requires 4 byte alignment
0x360386afc8d3: note: pointer points here
 36  00 00 e9 99 0f 05 00 00  00 00 00 00 00 00 00 00  03 00 00 00 00 00 00 68 
48 b9 24 96 e3 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior cmpintmd.c:235:4
cmpintmd.c:228:8: runtime error: load of misaligned address 0x360385f2961c for
type 'int64_t' (aka 'long'), which requires 8 byte alignment
0x360385f2961c: note: pointer points here
  03 03 38 00 00 00 00 00  00 00 00 00 48 3b 3e 0f  8d 8b 02 00 00 48 b8 09  00
00 00 00 00 00 20 50
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior cmpintmd.c:228:8
cmpintmd.c:75:25: runtime error: load of misaligned address 0x360385bab1d7 for
type 'int32_t' (aka 'int'), which requires 4 byte alignment
0x360385bab1d7: note: pointer points here
 00 00 00 e9 98  00 00 00 48 0f ba 2c 24  3c 48 b9 07 00 00 00 00  00 00 34 48
89 0f c7 47  08 01 00
             ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior cmpintmd.c:75:25
cmpintmd.c:41:47: runtime error: load of misaligned address 0x360385bab267 for
type 'uint16_t' (aka 'unsigned short'), which requires 2 byte alignment
0x360385bab267: note: pointer points here
 b8 00 00 00 80  82 06 09 00 00 00 00 00  00 00 00 48 8b 04 24 48  89 44 24 08
48 83 c4 08  48 8b 1d

... [many more of these]...

I suspect that the first few errors, "member access within null pointer of type
'struct fooalign'" and "applying non-zero offset 59388727439880 to null
pointer" are the cause of the problems.

This needs a bit more investigation.

-- 
You are receiving this mail because:
You are the assignee for the bug.