open-simh / simh

The Open SIMH simulators package
https://opensimh.org/
Other
486 stars 93 forks source link

Segmentation violation (make error 139) while building altairz80 simulator #164

Closed polaris6262 closed 1 year ago

polaris6262 commented 1 year ago
drawkula commented 1 year ago

Can you try this commit?

$ git log -n1
commit 1a1366650c38ed641d97335d56cf68b65b3c5720 (HEAD)
Author: Patrick Linstruth <patrick@deltecent.com>
Date:   Sun Jan 15 08:51:35 2023 -0800

    AltairZ80: Adds -H switch to LOAD command for loading Intel hex files
$ gmake clean
lib paths are: /usr/lib /usr/pkg/lib /lib/ /usr/lib/
include paths are:  /usr/include/gcc-7 /usr/include /usr/pkg/include
using libm: /usr/lib/libm.so
using librt: /usr/lib/librt.so
using libpthread: /usr/lib/libpthread.so /usr/include/pthread.h
using libpcre: /usr/pkg/lib/libpcre.so /usr/pkg/include/pcre.h
using semaphore: /usr/include/semaphore.h
using libdl: /usr/include/dlfcn.h
using libedit: /usr/pkg/include/editline/readline.h
using mman: /usr/include/sys/mman.h
rm -f -rf BIN/
$ gmake altairz80
lib paths are: /usr/lib /usr/pkg/lib /lib/ /usr/lib/
include paths are:  /usr/include/gcc-7 /usr/include /usr/pkg/include
using libm: /usr/lib/libm.so
using librt: /usr/lib/librt.so
using libpthread: /usr/lib/libpthread.so /usr/include/pthread.h
using libpcre: /usr/pkg/lib/libpcre.so /usr/pkg/include/pcre.h
using semaphore: /usr/include/semaphore.h
using libdl: /usr/include/dlfcn.h
using libedit: /usr/pkg/include/editline/readline.h
using mman: /usr/include/sys/mman.h
***
*** altairz80 Simulator being built with:
*** - compiler optimizations and no debugging support. GCC Version: 7.5.0.
*** - Per simulator tests will be run.
***
*** git commit id is 1a1366650c38ed641d97335d56cf68b65b3c5720.
*** git commit time is 2023-01-15T08:51:35-0800.
***
gcc -std=gnu99 -U__STRICT_ANSI__  -O2 -finline-functions -fgcse-after-reload -fpredictive-commoning -fipa-cp-clone -fno-unsafe-loop-optimizations -fno-strict-overflow -DSIM_GIT_COMMIT_ID=1a1366650c38ed641d97335d56cf68b65b3c5720 -DSIM_GIT_COMMIT_TIME=2023-01-15T08:51:35-0800  -DSIM_COMPILER="GCC Version: 7.5.0" -DSIM_BUILD_TOOL=simh-makefile -I . -Werror -D_GNU_SOURCE -I/usr/pkg/include -DUSE_READER_THREAD -DSIM_ASYNCH_IO  -DHAVE_PCRE_H -DHAVE_SEMAPHORE -DHAVE_SYS_IOCTL -DSIM_HAVE_DLOPEN=so -DHAVE_EDITLINE -DHAVE_UTIME -DHAVE_GLOB -DHAVE_SHM_OPEN  ./AltairZ80/altairz80_cpu.c ./AltairZ80/altairz80_cpu_nommu.c ./AltairZ80/mmd.c ./AltairZ80/s100_dj2d.c ./AltairZ80/s100_djhdc.c ./AltairZ80/altairz80_dsk.c ./AltairZ80/disasm.c ./AltairZ80/altairz80_sio.c ./AltairZ80/altairz80_sys.c ./AltairZ80/altairz80_hdsk.c ./AltairZ80/altairz80_net.c ./AltairZ80/s100_hayes.c ./AltairZ80/s100_2sio.c ./AltairZ80/s100_pmmi.c ./AltairZ80/flashwriter2.c ./AltairZ80/i86_decode.c ./AltairZ80/i86_ops.c ./AltairZ80/i86_prim_ops.c ./AltairZ80/i8272.c ./AltairZ80/insnsd.c ./AltairZ80/altairz80_mhdsk.c ./AltairZ80/mfdc.c ./AltairZ80/n8vem.c ./AltairZ80/vfdhd.c ./AltairZ80/s100_disk1a.c ./AltairZ80/s100_disk2.c ./AltairZ80/s100_disk3.c ./AltairZ80/s100_fif.c ./AltairZ80/s100_mdriveh.c ./AltairZ80/s100_icom.c ./AltairZ80/s100_jadedd.c ./AltairZ80/s100_mdsa.c ./AltairZ80/s100_mdsad.c ./AltairZ80/s100_selchan.c ./AltairZ80/s100_ss1.c ./AltairZ80/s100_64fdc.c ./AltairZ80/s100_scp300f.c ./AltairZ80/s100_tarbell.c ./AltairZ80/s100_tdd.c ./AltairZ80/wd179x.c ./AltairZ80/s100_hdc1001.c ./AltairZ80/s100_if3.c ./AltairZ80/s100_adcs6.c ./AltairZ80/m68k/m68kcpu.c ./AltairZ80/m68k/m68kdasm.c ./AltairZ80/m68k/m68kasm.c ./AltairZ80/m68k/m68kopac.c ./AltairZ80/m68k/m68kopdm.c ./AltairZ80/m68k/softfloat/softfloat.c ./AltairZ80/m68k/m68kopnz.c ./AltairZ80/m68k/m68kops.c ./AltairZ80/m68ksim.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 -I ./AltairZ80 -o BIN/altairz80 -L/usr/pkg/lib -R/usr/pkg/lib -lm -lrt -lpthread -lpcre -L/usr/pkg/lib/ -ledit -ltermcap  
BIN/altairz80 RegisterSanityCheck  </dev/null 
 Running internal register sanity checks on Altair 8800 (Z80) simulator.
*** Good Registers in Altair 8800 (Z80) simulator.
$ █ 

While rolling back, that is the 1st one that doesn't coredump on self-testing for me.

markpizz commented 1 year ago

I don't see any such failure on at least 5 platforms I've tested.

Both of you (@polaris6262 and @drawkula) seem to have different platforms since the compilers are very different. Will you identify what host systems (and versions) you are seeing this problem on?

drawkula commented 1 year ago

Debian11/amd64 gcc (Debian 10.2.1-6) 10.2.1 20210110

NetBSD9/amd64 gcc (nb4 20200810) 7.5.0

The rolling back commits above was done on NetBSD9.

psco commented 1 year ago

It appears that the failure is not always happening. On Ubuntu 22.10 you might need to try multiple times before a segmentation fault occurs. On macOS I haven't seen a segmentation fault so far.

% BIN/altairz80                    

Altair 8800 (Z80) simulator Open SIMH V4.1-0 Current        git commit id: 2374c3b6
sim> show version
Altair 8800 (Z80) simulator Open SIMH V4.1-0 Current
    Simulator Framework Capabilities:
        32b data
        32b addresses
        no Ethernet
        Idle/Throttling support is available
        Virtual Hard Disk (VHD) support
        RAW disk and CD/DVD ROM support
        Asynchronous I/O support (Lock free asynchronous event queue)
        Asynchronous Clock support
        FrontPanel API Version 12
    Host Platform:
        Compiler: GCC 12.2.0
        Simulator Compiled as C arch: x64 (Release Build) on Feb  6 2023 at 16:55:13
        Build Tool: simh-makefile
        Memory Access: Little Endian
        Memory Pointer Size: 64 bits
        Large File (>2GB) support
        SDL Video support: No Video Support
        PCRE RegEx (Version 8.39 2016-06-14) support for EXPECT commands
        OS clock resolution: 1ms
        Time taken by msleep(1): 1ms
        OS: Linux ubu2210 5.19.0-29-generic #30-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 4 12:14:09 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
        Processor Name: Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
        tar tool: tar (GNU tar) 1.34
        curl tool: curl 7.85.0 (x86_64-pc-linux-gnu) libcurl/7.85.0 OpenSSL/3.0.5 zlib/1.2.11 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.3 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.49.0 librtmp/2.3
        git commit id: 2374c3b6
        git commit time: 2023-02-02T14:56:33-0500
sim> bye
Goodbye
peterschorn@ubu2210 ~/simh_git/simh
 % BIN/altairz80 RegisterSanityCheck
 Running internal register sanity checks on Altair 8800 (Z80) simulator.
*** Good Registers in Altair 8800 (Z80) simulator.
peterschorn@ubu2210 ~/simh_git/simh
 % BIN/altairz80 RegisterSanityCheck
 Running internal register sanity checks on Altair 8800 (Z80) simulator.
*** Good Registers in Altair 8800 (Z80) simulator.
peterschorn@ubu2210 ~/simh_git/simh
 % BIN/altairz80 RegisterSanityCheck
 Running internal register sanity checks on Altair 8800 (Z80) simulator.
*** Good Registers in Altair 8800 (Z80) simulator.
peterschorn@ubu2210 ~/simh_git/simh
 % BIN/altairz80 RegisterSanityCheck
 Running internal register sanity checks on Altair 8800 (Z80) simulator.
*** Good Registers in Altair 8800 (Z80) simulator.
peterschorn@ubu2210 ~/simh_git/simh
 % BIN/altairz80 RegisterSanityCheck
 Running internal register sanity checks on Altair 8800 (Z80) simulator.
*** Good Registers in Altair 8800 (Z80) simulator.
peterschorn@ubu2210 ~/simh_git/simh
 % BIN/altairz80 RegisterSanityCheck
 Running internal register sanity checks on Altair 8800 (Z80) simulator.
*** Good Registers in Altair 8800 (Z80) simulator.
zsh: segmentation fault (core dumped)  BIN/altairz80 RegisterSanityCheck
peterschorn@ubu2210 ~/simh_git/simh
 % 
% make altairz80                   
lib paths are: /lib/x86_64-linux-gnu/ /lib/ /usr/lib/
include paths are:  /usr/lib/gcc/x86_64-linux-gnu/12/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include
using libm: /lib/x86_64-linux-gnu/libm.so
using librt: /lib/x86_64-linux-gnu/librt.a
using libpthread: /lib/x86_64-linux-gnu/libpthread.a /usr/include/pthread.h
using libpcre: /lib/x86_64-linux-gnu/libpcre.so /usr/include/pcre.h
using semaphore: /usr/include/semaphore.h
using libdl: /lib/x86_64-linux-gnu/libdl.a /usr/include/dlfcn.h
using libpng: /lib/x86_64-linux-gnu/libpng.so /usr/include/png.h
using zlib: /lib/x86_64-linux-gnu/libz.so /usr/include/zlib.h
using mman: /usr/include/x86_64-linux-gnu/sys/mman.h
***
*** altairz80 Simulator being built with:
*** - compiler optimizations and no debugging support. GCC Version: 12.2.0.
*** - Per simulator tests will be run.
***
*** git commit id is 2374c3b6b3e26f8920a50297ad7422d35aa769c7.
*** git commit time is 2023-02-02T14:56:33-0500.
***
gcc -std=gnu99 -U__STRICT_ANSI__  -O2 -finline-functions -fgcse-after-reload -fpredictive-commoning -fipa-cp-clone -fno-unsafe-loop-optimizations -fno-strict-overflow -DSIM_GIT_COMMIT_ID=2374c3b6b3e26f8920a50297ad7422d35aa769c7 -DSIM_GIT_COMMIT_TIME=2023-02-02T14:56:33-0500  -DSIM_COMPILER="GCC Version: 12.2.0" -DSIM_BUILD_TOOL=simh-makefile -I . -Werror -D_GNU_SOURCE -DUSE_READER_THREAD -DSIM_ASYNCH_IO  -DHAVE_PCRE_H -DHAVE_SEMAPHORE -DHAVE_SYS_IOCTL -DHAVE_LINUX_CDROM -DSIM_HAVE_DLOPEN=so -DHAVE_UTIME -DHAVE_LIBPNG -DHAVE_ZLIB -DHAVE_GLOB -DHAVE_SHM_OPEN  ./AltairZ80/altairz80_cpu.c ./AltairZ80/altairz80_cpu_nommu.c ./AltairZ80/mmd.c ./AltairZ80/s100_dj2d.c ./AltairZ80/s100_djhdc.c ./AltairZ80/altairz80_dsk.c ./AltairZ80/disasm.c ./AltairZ80/altairz80_sio.c ./AltairZ80/altairz80_sys.c ./AltairZ80/altairz80_hdsk.c ./AltairZ80/altairz80_net.c ./AltairZ80/s100_hayes.c ./AltairZ80/s100_2sio.c ./AltairZ80/s100_pmmi.c ./AltairZ80/flashwriter2.c ./AltairZ80/i86_decode.c ./AltairZ80/i86_ops.c ./AltairZ80/i86_prim_ops.c ./AltairZ80/i8272.c ./AltairZ80/insnsd.c ./AltairZ80/altairz80_mhdsk.c ./AltairZ80/mfdc.c ./AltairZ80/n8vem.c ./AltairZ80/vfdhd.c ./AltairZ80/s100_disk1a.c ./AltairZ80/s100_disk2.c ./AltairZ80/s100_disk3.c ./AltairZ80/s100_fif.c ./AltairZ80/s100_mdriveh.c ./AltairZ80/s100_icom.c ./AltairZ80/s100_jadedd.c ./AltairZ80/s100_mdsa.c ./AltairZ80/s100_mdsad.c ./AltairZ80/s100_selchan.c ./AltairZ80/s100_ss1.c ./AltairZ80/s100_64fdc.c ./AltairZ80/s100_scp300f.c ./AltairZ80/s100_tarbell.c ./AltairZ80/s100_tdd.c ./AltairZ80/wd179x.c ./AltairZ80/s100_hdc1001.c ./AltairZ80/s100_if3.c ./AltairZ80/s100_adcs6.c ./AltairZ80/m68k/m68kcpu.c ./AltairZ80/m68k/m68kdasm.c ./AltairZ80/m68k/m68kasm.c ./AltairZ80/m68k/m68kopac.c ./AltairZ80/m68k/m68kopdm.c ./AltairZ80/m68k/softfloat/softfloat.c ./AltairZ80/m68k/m68kopnz.c ./AltairZ80/m68k/m68kops.c ./AltairZ80/m68ksim.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 -I ./AltairZ80 -o BIN/altairz80 -lm -lrt -lpthread -lpcre -ldl -lpng -lz  
BIN/altairz80 RegisterSanityCheck  </dev/null 
 Running internal register sanity checks on Altair 8800 (Z80) simulator.
*** Good Registers in Altair 8800 (Z80) simulator.
peterschorn@ubu2210 ~/simh_git/simh
 % BIN/altairz80 RegisterSanityCheck
 Running internal register sanity checks on Altair 8800 (Z80) simulator.
*** Good Registers in Altair 8800 (Z80) simulator.
zsh: segmentation fault (core dumped)  BIN/altairz80 RegisterSanityCheck
 %
markpizz commented 1 year ago

I just tracked this down and sent @hharte the details of how to fix and why it happened. Expect a PR from him soon.

markpizz commented 1 year ago

This issue is fixed by @hharte's PR and should be closed.