NetBSD Problem Report #60875
From www@netbsd.org Wed Oct 14 10:04:20 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 33D9F1A923B
for <gnats-bugs@gnats.NetBSD.org>; Wed, 14 Oct 2026 10:04:20 +0000 (UTC)
Message-Id: <20261014100418.D3D6D1A923C@mollari.NetBSD.org>
Date: Wed, 14 Oct 2026 10:04:18 +0000 (UTC)
From: rokuyama.rk@gmail.com
Reply-To: rokuyama.rk@gmail.com
To: gnats-bugs@NetBSD.org
Subject: open-simh: miscompiled by GCC on NetBSD/amd64
X-Send-Pr-Version: www-1.0
X-From4GNATS: "rokuyama.rk@gmail.com via gnats" <gnats-admin@NetBSD.org>
>Number: 60875
>Category: pkg
>Synopsis: open-simh: miscompiled by GCC on NetBSD/amd64
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: rhialto
>State: analyzed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Oct 14 10:05:00 +0000 2026
>Closed-Date:
>Last-Modified: Thu Oct 15 12:00:02 +0000 2026
>Originator: Rin Okuyama
>Release: 11.99.9 and 2026Q3
>Organization:
Internet Initiative Japan Inc.
>Environment:
NetBSD sakaizumii.local 11.99.9 NetBSD 11.99.9 (AMD64_NET_MPSAFE) #2: Sat Oct 10 17:06:17 JST 2026 rin@sakaizumii.local:/home/rin/src/sys/arch/amd64/compile/AMD64_NET_MPSAFE amd64
>Description:
For open-simh-4.1.0.20260413nb2 on NetBSD/amd64-current, "normal
system test 31" fails:
```
% simh-vax NetBSD-11.99.9-vax-live.boot
MicroVAX 3900 simulator Open SIMH V4.1-0 Current simh git commit id: 7994e0a7 Build: Unsupported=include+lib
/old/home/rin/vax/NetBSD-11.99.9-vax-live.boot-9> attach xq tap:tap0
%SIM-INFO: Eth: opened OS device tap0
KA655X-B V5.3, VMB 2.7
Performing normal system tests.
40..39..38..37..36..35..34..33..32..31..
?53 2 07 FF 00 0000
P1=00000002 P2=00000028 P3=00000000 P4=00D40077 P5=00000000
P6=FFFFFFFF P7=00000000 P8=00000000 P9=00000000 P10=20051CE0
r0=A380D3C6 r1=20140110 r2=A380D3C7 r3=00000000 r4=A380D3D1
r5=2004E8F9 r6=000F4240 r7=80000011 r8=00000000 ERF=80000000
30..29..28..27..26..25..
24..23..22..21..20..19..18..17..16..15..14..13..12..11..10..09..
08..07..06..05..04..03..
Normal operation not possible.
>>>
```
I'm using this config file:
```
load -r ka655x.bin
set cpu 256m
set cpu idle=netbsd
set rq0 ra92
at rq0 NetBSD-11.99.9-vax-live.img
attach xq tap:tap0
boot cpu
```
and ka655x.bin acquired from here:
https://github.com/simh/simh/blob/master/VAX/ka655x.bin
This failure happens with GCC 10.5 (from netbsd-10 branch), 12.5,
and 14.4.
In order to work around, compile open-simh with -O3 or -O1 on
NetBSD/amd64. I've confirmed that full ATF run of NetBSD/vax on
-O3 compiled open-simh successfully completes with GCC 10.5, 12.5,
and 14.4.
I haven't tested emulators other than simh-vax on the other hand.
>How-To-Repeat:
Described above.
>Fix:
diff --git a/emulators/open-simh/Makefile b/emulators/open-simh/Makefile
index 857d0db21ced..3f18d6ed4f38 100644
--- a/emulators/open-simh/Makefile
+++ b/emulators/open-simh/Makefile
@@ -2,7 +2,7 @@
DISTNAME= open-simh-4.1.0
PKGNAME= open-simh-4.1.0.20260413
-PKGREVISION= 2
+PKGREVISION= 3
CATEGORIES= emulators
MASTER_SITES= ${MASTER_SITE_GITHUB:=open-simh/}
GITHUB_PROJECT= simh
diff --git a/emulators/open-simh/hacks.mk b/emulators/open-simh/hacks.mk
new file mode 100644
index 000000000000..b972dc59cfe2
--- /dev/null
+++ b/emulators/open-simh/hacks.mk
@@ -0,0 +1,14 @@
+# $NetBSD$
+
+.if !defined(OPEN_SIMH_HACKS_MK)
+OPEN_SIMH_HACKS_MK= defined
+
+.include "../../mk/compiler.mk"
+
+# For simh-vax, "normal system tests 31" fails.
+.if ${MACHINE_PLATFORM:MNetBSD-*-x86_64} && ${CC_VERSION:Mgcc-*}
+PKG_HACKS+= optimisation
+BUILDLINK_TRANSFORM+= opt:-O2:-O3
+.endif
+
+.endif # OPEN_SIMH_HACKS_MK
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: pkg-manager->rhialto
Responsible-Changed-By: rin@NetBSD.org
Responsible-Changed-When: Wed, 14 Oct 2026 10:07:15 +0000
Responsible-Changed-Why:
Over to maintainer; can you please take a look?
From: Rhialto <rhialto@falu.nl>
To: gnats-bugs@netbsd.org
Cc: rhialto@netbsd.org, pkg-manager@netbsd.org, pkgsrc-bugs@netbsd.org,
gnats-admin@netbsd.org, rin@NetBSD.org, rokuyama.rk@gmail.com
Subject: Re: pkg/60875 (open-simh: miscompiled by GCC on NetBSD/amd64)
Date: Wed, 14 Oct 2026 21:50:46 +0200
I tried to reproduce this in my own environment (NetBSD 11.0 amd64 with
gcc 12.5.0 from base) but did not succeed. (I attached a different disk
image which I had at hand, but that should make no difference, since it
is never read)
This does not prove much, because the upstream code relies on UB
(undefined behavior) especially in the VAX code. The most obvious one is
that it assumes that overflow of signed integers works the same as with
unsigned integers. They are relucant to change the code: a long time ago
it has been validated with proprietary DEC instruction set validation
tests, and those are no longer available.
Due to the UB, there is a large number of compiler options to try to
make it work anyway. It could be that in your compilation some of these
are missing (due to a different environment). If this is the case,
fixing that may fix the issue.
I also tried
https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/11.0_2026Q3/All/op=
en-simh-4.1.0.20260413nb2.tgz
and it did not reproduce the issue either.
I have compile commands like this:
gcc -std=3Dgnu99 -U__STRICT_ANSI__ -fno-strict-overflow
-finline-functions -fpredictive-commoning -fipa-cp-clone
-fgcse-after-reload -fno-unsafe-loop-optimizations -O2 -DNDEBUG=3D1
-finline-functions -fgcse-after-reload -fpredictive-commoning
-fipa-cp-clone -fno-unsafe-loop-optimizations -fno-strict-overflow
-DSIM_BUILD=3DUnsupported=3Dinclude+lib -DSIM_COMPILER=3D"GCC Version:
12.5.0" -DSIM_BUILD_TOOL=3Dsimh-makefile -I . -D_GNU_SOURCE -DHAVE_PCR=
E_H
-DHAVE_SEMAPHORE -DHAVE_SYS_IOCTL -DSIM_HAVE_DLOPEN=3Dso -DHAVE_EDITLINE
-DHAVE_UTIME -DHAVE_LIBPNG -DHAVE_ZLIB -DHAVE_GLOB -DHAVE_SHM_OPEN
./VAX/vax_cpu.c ./VAX/vax_cpu1.c ./VAX/vax_fpa.c ./VAX/vax_io.c
./VAX/vax_cis.c ./VAX/vax_octa.c ./VAX/vax_cmode.c./VAX/vax_mmu.c
./VAX/vax_stddev.c ./VAX/vax_sysdev.c ./VAX/vax_sys.c ./VAX/vax_syscm.c
./VAX/vax_syslist.c ./VAX/vax_vc.c ./VAX/vax_lk.c ./VAX/vax_vs.c
./VAX/vax_2681.c ./PDP11/pdp11_rl.c ./PDP11/pdp11_rq.c
./PDP11/pdp11_ts.c ./PDP11/pdp11_dz.c ./PDP11/pdp11_lp.c
./PDP11/pdp11_tq.c ./PDP11/pdp11_xq.c ./PDP11/pdp11_vh.c
./PDP11/pdp11_cr.c ./PDP11/pdp11_td.c ./PDP11/pdp11_io_lib.c
./PDP11/pdp11_dup.c ./scp.c ./sim_console.c ./sim_fio.c ./sim_timer.c
./sim_sock.c ./sim_tmxr.c ./sim_ether.c ./sim_tape.c ./sim_disk.c
./sim_serial.c ./sim_video.c ./sim_imd.c ./sim_card.c -DVM_VAX
-DUSE_INT64 -DUSE_ADDR64 -DUSE_SIM_VIDEO -I ./VAX -I ./PDP11
-DHAVE_PCAP_NETWORK -I/usr/include/pcap/ -DBPF_CONST_STRING
-DUSE_NETWORK -DHAVE_VDE_NETWORK -DHAVE_TAP_NETWORK -DHAVE_BSDTUNTAP
-Islirp -Islirp_glue -Islirp_glue/qemu -DHAVE_SLIRP_NETWORK
-DUSE_SIMH_SLIRP_DEBUG slirp/*.c slirp_glue/*.c -DHAVE_LIBSDL
-DUSE_SIM_VIDEO `sdl2-config --cflags` `sdl2-config --libs`
-DUSE_READER_THREAD -DSIM_ASYNCH_IO -o BIN/vax -Wl,-zrelro
-L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib
-L/usr/lib -Wl,-R/usr/lib -lm -lrt -lpthread -lpcre -L/usr/pkg/lib/
-ledit -ltermcap -lpng16 -lz -lpcap -lvdeplug -Wl,-R,/usr/pkg/lib/
-L/usr/pkg/lib/
(You can ignore references to VDE or vdeplug; this refers to wip/vde2)
Aside: the config line "load -r ka655x.bin" should not be needed, since
the same file is built-in. Simh will say "%SIM-INFO: Loading boot code
=66rom internal ka655x.bin"
It may be that adding -Wstrict-overflow=3D5 shows some useful diagnostic.
If this does not show any missing options, I have no objection if you
commit the changes you propose.
-Olaf.
--=20
___ Olaf 'Rhialto' Seibert <rhialto/at/falu.nl>
\X/ There is no AI. There is just someone else's work. --I. Rose
State-Changed-From-To: open->analyzed
State-Changed-By: rin@NetBSD.org
State-Changed-When: Thu, 15 Oct 2026 11:58:46 +0000
State-Changed-Why:
I couldn't reproduce the problem with official buit package of
2026Q3 for netbsd-11. So, this may be my local settings...
From: Rin Okuyama <rokuyama.rk@gmail.com>
To: Rhialto <rhialto@falu.nl>, gnats-bugs@netbsd.org
Cc: rhialto@netbsd.org, pkg-manager@netbsd.org, pkgsrc-bugs@netbsd.org,
gnats-admin@netbsd.org
Subject: Re: pkg/60875 (open-simh: miscompiled by GCC on NetBSD/amd64)
Date: Thu, 15 Oct 2026 20:57:17 +0900
Thank you very much for kind explanation!
On 2026/10/15 4:50, Rhialto wrote:
> I tried to reproduce this in my own environment (NetBSD 11.0 amd64 with
> gcc 12.5.0 from base) but did not succeed. (I attached a different disk
> image which I had at hand, but that should make no difference, since it
> is never read)
>
> This does not prove much, because the upstream code relies on UB
> (undefined behavior) especially in the VAX code. The most obvious one is
> that it assumes that overflow of signed integers works the same as with
> unsigned integers. They are relucant to change the code: a long time ago
> it has been validated with proprietary DEC instruction set validation
> tests, and those are no longer available.
>
> Due to the UB, there is a large number of compiler options to try to
> make it work anyway. It could be that in your compilation some of these
> are missing (due to a different environment). If this is the case,
> fixing that may fix the issue.
>
> I also tried
> https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/11.0_2026Q3/All/open-simh-4.1.0.20260413nb2.tgz
> and it did not reproduce the issue either.
I tried that package, and I also couldn't reproduce the problem.
So, this may be my local settings, but I haven't figured out what
causes the problem...
> I have compile commands like this:
>
> gcc -std=gnu99 -U__STRICT_ANSI__ -fno-strict-overflow
> -finline-functions -fpredictive-commoning -fipa-cp-clone
> -fgcse-after-reload -fno-unsafe-loop-optimizations -O2 -DNDEBUG=1
> -finline-functions -fgcse-after-reload -fpredictive-commoning
> -fipa-cp-clone -fno-unsafe-loop-optimizations -fno-strict-overflow
> -DSIM_BUILD=Unsupported=include+lib -DSIM_COMPILER="GCC Version:
> 12.5.0" -DSIM_BUILD_TOOL=simh-makefile -I . -D_GNU_SOURCE -DHAVE_PCRE_H
> -DHAVE_SEMAPHORE -DHAVE_SYS_IOCTL -DSIM_HAVE_DLOPEN=so -DHAVE_EDITLINE
> -DHAVE_UTIME -DHAVE_LIBPNG -DHAVE_ZLIB -DHAVE_GLOB -DHAVE_SHM_OPEN
> ./VAX/vax_cpu.c ./VAX/vax_cpu1.c ./VAX/vax_fpa.c ./VAX/vax_io.c
> ./VAX/vax_cis.c ./VAX/vax_octa.c ./VAX/vax_cmode.c./VAX/vax_mmu.c
> ./VAX/vax_stddev.c ./VAX/vax_sysdev.c ./VAX/vax_sys.c ./VAX/vax_syscm.c
> ./VAX/vax_syslist.c ./VAX/vax_vc.c ./VAX/vax_lk.c ./VAX/vax_vs.c
> ./VAX/vax_2681.c ./PDP11/pdp11_rl.c ./PDP11/pdp11_rq.c
> ./PDP11/pdp11_ts.c ./PDP11/pdp11_dz.c ./PDP11/pdp11_lp.c
> ./PDP11/pdp11_tq.c ./PDP11/pdp11_xq.c ./PDP11/pdp11_vh.c
> ./PDP11/pdp11_cr.c ./PDP11/pdp11_td.c ./PDP11/pdp11_io_lib.c
> ./PDP11/pdp11_dup.c ./scp.c ./sim_console.c ./sim_fio.c ./sim_timer.c
> ./sim_sock.c ./sim_tmxr.c ./sim_ether.c ./sim_tape.c ./sim_disk.c
> ./sim_serial.c ./sim_video.c ./sim_imd.c ./sim_card.c -DVM_VAX
> -DUSE_INT64 -DUSE_ADDR64 -DUSE_SIM_VIDEO -I ./VAX -I ./PDP11
> -DHAVE_PCAP_NETWORK -I/usr/include/pcap/ -DBPF_CONST_STRING
> -DUSE_NETWORK -DHAVE_VDE_NETWORK -DHAVE_TAP_NETWORK -DHAVE_BSDTUNTAP
> -Islirp -Islirp_glue -Islirp_glue/qemu -DHAVE_SLIRP_NETWORK
> -DUSE_SIMH_SLIRP_DEBUG slirp/*.c slirp_glue/*.c -DHAVE_LIBSDL
> -DUSE_SIM_VIDEO `sdl2-config --cflags` `sdl2-config --libs`
> -DUSE_READER_THREAD -DSIM_ASYNCH_IO -o BIN/vax -Wl,-zrelro
> -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib
> -L/usr/lib -Wl,-R/usr/lib -lm -lrt -lpthread -lpcre -L/usr/pkg/lib/
> -ledit -ltermcap -lpng16 -lz -lpcap -lvdeplug -Wl,-R,/usr/pkg/lib/
> -L/usr/pkg/lib/
>
> (You can ignore references to VDE or vdeplug; this refers to wip/vde2)
Compile command completely coincides except for VDE arguments.
> Aside: the config line "load -r ka655x.bin" should not be needed, since
> the same file is built-in. Simh will say "%SIM-INFO: Loading boot code
> from internal ka655x.bin"
I tried both internal and external ka655x.bin, but result does
not changed.
> It may be that adding -Wstrict-overflow=5 shows some useful diagnostic.
Ah, yes, disabling -fno-strict-overflow and adding -Wstrict-overflow=5
result in a lot of compiler warnings...
> If this does not show any missing options, I have no objection if you
> commit the changes you propose.
As I couldn't reproduce the problem with public build of 2026Q3 for
netbsd-11, I hesitate to commit my suggested changes...
I will change this PR to analyzed until when anyone who can reproduce
my problem.
> -Olaf.
Thanks,
rin
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.