rofl0r / arnold

arnold cpc emulator
GNU General Public License v2.0
11 stars 5 forks source link

Segment fault when I select 464+ or 6128+ (Ubuntu 18.04) #3

Closed cpcbegin closed 3 years ago

cpcbegin commented 4 years ago

The emulator runs ok if I select CPC464, CPC664, CPC6128 & KC Compact but crash if I select 464+ or 6128+

I compile the emulator in Ubuntu 18.04 64 bits with these commands:

sudo apt install git build-essential libgtk2.0-dev libsdl1.2-dev libx11-dev
git clone https://github.com/rofl0r/arnold
cd arnold
git pull
cd src
./autogen.sh
./configure
make
Chouzinho commented 4 years ago

The same happens to me in Lubuntu 20.04. It works for cpc classic, but when I start the 6128 plus emulation, it crashes and gives a "segmentation fault"

rofl0r commented 4 years ago

thanks for the report. i suspect it is due to some undefined behavior exploited by newer gcc versions. you could try with an older gcc (for example if the binary is called gcc-6.4.0 run configure like CC=gcc-6.4.0 ./configure). also it would be interesting to see the warnings emitted by the gcc you use (run make >/dev/null 2>log.txt to get a file called log.txt containing all the warnings) so we can fix that.

cpcbegin commented 3 years ago

I change configure as you want and I get the same error. Now I'm trying with Ubuntu 20.04.

rofl0r commented 3 years ago

and, are there any warnings ? also each segfault report should be accompanied by a backtrace, produced by running the executable (optimally built with debug info) with gdb and typing bt when the segfault happens.

rofl0r commented 3 years ago

i just fixed the only crash that happened for me, but cpc+ setting seems to work fine.

cpcbegin commented 3 years ago

No, the emulator stop working as you can see in this short video. arnold-stop-working-2020-11-25_00-06-14

rofl0r commented 3 years ago

ok, could you run gdb --args ./arnold instead, then hit "r" enter, wait for the crash, then type "bt" enter and show me the backtrace ?

cpcbegin commented 3 years ago
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./arnold...
(gdb) r
Starting program: /opt/linuxemus/arnoldrofl0r/src/arnold 
[Depuración de hilo usando libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Arnold Emulator (c) Kevin Thacker
Linux Port maintained by Andreas Micklei
----------------------------------------------------------
Compiled in ROMS:
  Amsdos    : 5559d010 to 555a1010, 1431666688 (0x55558000) bytes
  464   OS   : 555a1010 to 555a5010, 1431666688 (0x55558000) bytes
  464   Basic: 555a5010 to 555a9010, 1431666688 (0x55558000) bytes
  664   OS   : 555a9010 to 555ad010, 1431666688 (0x55558000) bytes
  664   Basic: 555ad010 to 555b1010, 1431666688 (0x55558000) bytes
  6128  OS   : 555b1010 to 555b5010, 1431666688 (0x55558000) bytes
  6128  Basic: 555b5010 to 555b9010, 1431666688 (0x55558000) bytes
  6128s OS   : 555b9010 to 555bd010, 1431666688 (0x55558000) bytes
  6128s Basic: 555bd010 to 555c1010, 1431666688 (0x55558000) bytes
  plus  Cart : 555c1010 to 555e1064, 1431781460 (0x55574054) bytes
  kcc   OS   : 555e1064 to 555e5064, 1431666688 (0x55558000) bytes
  kcc   Basic: 555e5064 to 555e9064, 1431666688 (0x55558000) bytes
----------------------------------------------------------
Opening /home/bobu/.arnold
Parsing /home/bobu/.arnold
tape: (null)
kbdtype: -1
[Nuevo Thread 0x7ffff19cd700 (LWP 5352)]
set_hwparams
Unable to set periods 2 for playback: Invalid argument
Setting of hwparams failed: Invalid argument
alsa_AudioPlaybackPossible(void): 0
/dev/dsp: No such file or directory
oss_AudioPlaybackPossible(void): 0
soundplugin: 0 (NONE)
Initializing SDL
[Nuevo Thread 0x7ffff11cc700 (LWP 5353)]
[Nuevo Thread 0x7fffdbfff700 (LWP 5354)]
[Thread 0x7fffdbfff700 (LWP 5354) terminado]
sdl_InitialiseKeyboardMapping(0)
Found 0 Joysticks
Initializing GTK+
[Nuevo Thread 0x7fffdbfff700 (LWP 5355)]
[Nuevo Thread 0x7fffdff36700 (LWP 5356)]
[Nuevo Thread 0x7fffdf735700 (LWP 5357)]
[Nuevo Thread 0x7fffdeee6700 (LWP 5358)]
Audio: 1
Joysticks: 1
Could not open /dev/console: Permiso denegado
Keyboard LED flashing will be disabled.
Opening window with resolution 384*272*0
BPP: 32
Red: M: 00ff0000 B: 8 S: 16
Green: M: 0000ff00 B: 8 S: 8
Blue: M: 000000ff B: 8 S: 0
Initialised CPC Emulation Core...
Initialised Audio...
Choose cpctype CPC 6128+ (5)

Thread 1 "arnold" received signal SIGSEGV, Segmentation fault.
0x0000555555578b43 in Z80_RD_OPCODE_BYTE (Offset=<optimized out>)
    at cpc/z80/z80.c:9782
9782    switch (Opcode)
(gdb) bt
#0  0x0000555555578b43 in Z80_RD_OPCODE_BYTE (Offset=<optimized out>)
    at cpc/z80/z80.c:9782
#1  Z80_ExecuteInstruction () at cpc/z80/z80.c:9780
#2  0x000055555556ae55 in Debugger_Execute () at cpc/debugger/gdebug.c:152
#3  0x0000555555559c05 in CPCEmulation_Run () at cpc/arnold.c:344
#4  0x0000555555586f51 in idlerun (data=<optimized out>) at unix/gtkui.c:820
#5  0x00007ffff7a0fe8e in g_main_context_dispatch ()
    at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007ffff7a10240 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#7  0x00007ffff7a10533 in g_main_loop_run ()
    at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#8  0x00007ffff7c82092 in gtk_main ()
    at /lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#9  0x000055555558865b in gtkui_run () at unix/gtkui.c:859
#10 0x0000555555584d95 in init_main (argc=1, argv=0x7fffffffdff8)
    at unix/main.c:461
#11 0x0000555555559980 in main (argc=1, argv=0x7fffffffdff8) at unix/main.c:169
(gdb) 
rofl0r commented 3 years ago

thanks, the output was helpful. the issue was caused because your toolchain seems to default to create position-independent-executables (PIE). i was able to reproduce it and develop a fix.