Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

causes (?) SIGFPE in video-rice #43

Open
bugfood opened this issue Jan 23, 2019 · 0 comments
Open

causes (?) SIGFPE in video-rice #43

bugfood opened this issue Jan 23, 2019 · 0 comments

Comments

@bugfood
Copy link

bugfood commented Jan 23, 2019

I do not know if this bug report belongs here or in video-rice, but when I use video-rice with rsp-cxd4, I get an FPE. I traced the problem far enough back to see that this is happening because of a bit field overflow in video-rice:
src/RSP_Parser.cpp, DLParser_SetCImg()
dwWidth=4096 overflows newCI.dwWidth, declared as 10 bits

$ gdb --args /usr/local/src/mupen64plus/install//bin/mupen64plus --rsp mupen64plus-rsp-cxd4-sse2.so --nosaveoptions --plugindir /usr/local/src/mupen64plus/install//lib/mupen64plus --datadir /usr/local/src/mupen64plus/install//share/mupen64plus --corelib /usr/local/src/mupen64plus/install//lib/libmupen64plus.so.2  /tmp/Zelda64.rom 
GNU gdb (Debian 8.2-1) 8.2
Copyright (C) 2018 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 /usr/local/src/mupen64plus/install//bin/mupen64plus...done.
(gdb) r
Starting program: /usr/local/src/mupen64plus/install/bin/mupen64plus --rsp mupen64plus-rsp-cxd4-sse2.so --nosaveoptions --plugindir /usr/local/src/mupen64plus/install//lib/mupen64plus --datadir /usr/local/src/mupen64plus/install//share/mupen64plus --corelib /usr/local/src/mupen64plus/install//lib/libmupen64plus.so.2 /tmp/Zelda64.rom
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
 __  __                         __   _  _   ____  _             
|  \/  |_   _ _ __   ___ _ __  / /_ | || | |  _ \| |_   _ ___ 
| |\/| | | | | '_ \ / _ \ '_ \| '_ \| || |_| |_) | | | | / __|  
| |  | | |_| | |_) |  __/ | | | (_) |__   _|  __/| | |_| \__ \  
|_|  |_|\__,_| .__/ \___|_| |_|\___/   |_| |_|   |_|\__,_|___/  
             |_|         https://mupen64plus.org/               
Mupen64Plus Console User-Interface Version 2.5.0

UI-Console: attached to core library 'Mupen64Plus Core' version 2.5.1
UI-Console:             Includes support for Dynamic Recompiler.
Core: Using full mem base
[New Thread 0x7fffcec1d700 (LWP 17460)]
Core: Goodname: Legend of Zelda, The - Ocarina of Time (U) (V1.0) [!]
Core: Name: THE LEGEND OF ZELDA 
Core: MD5: 5BD1FE107BF8106B2AB6650ABECD54D6
Core: CRC: EC7011B7 7616D72B
Core: Imagetype: .z64 (native)
Core: Rom size: 33554432 bytes (or 32 Mb or 256 Megabits)
Core: Version: 1449
Core: Manufacturer: 43
Core: Country: USA
UI-Console Status: Cheat codes disabled.
UI-Console: using Video plugin: 'Mupen64Plus OpenGL Video Plugin by Rice' v2.5.0
UI-Console: using Audio plugin: 'Mupen64Plus SDL Audio Plugin' v2.5.0
UI-Console: using Input plugin: 'Mupen64Plus SDL Input Plugin' v2.5.0
UI-Console: using RSP plugin: 'Static Interpreter' v0.1.1
Input: 1 SDL joysticks were found.
Input: N64 Controller #1: Using manual config for SDL joystick 0
Input: N64 Controller #2: Using manual config with no SDL joystick (keyboard/mouse only)
Input: N64 Controller #3: Using manual config with no SDL joystick (keyboard/mouse only)
Input: N64 Controller #4: Using manual config with no SDL joystick (keyboard/mouse only)
Input: 4 controller(s) found, 1 plugged in and usable in the emulator
Input: Rumble activated on N64 joystick #1
Input Warning: Couldn't open rumble support for joystick #2
Input Warning: Couldn't open rumble support for joystick #3
Input Warning: Couldn't open rumble support for joystick #4
Input: Mupen64Plus SDL Input Plugin version 2.5.0 initialized.

Thread 1 "mupen64plus" received signal SIGSEGV, Segmentation fault.
0x00007ffff7fb24dd in InitiateRSP (Rsp_Info=..., CycleCount=0x0) at ../..//module.c:487
487	        SR[at] += DRAM[SR[ra]];
(gdb) c
Continuing.
Core: Using video capture backend: dummy
Core: Game controller 0 (Standard controller) has a Memory pak plugged in
Core: Game controller 1 (Standard controller) has a Memory pak plugged in
Core: Game controller 2 (Standard controller) has a Memory pak plugged in
Core: Game controller 3 (Standard controller) has a Memory pak plugged in
Core: Using CIC type X105
Video: SSE processing enabled.
Video: Found ROM 'THE LEGEND OF ZELDA', CRC b71170ec2bd71676-45
Video: Enabled hacks for game: 'THE LEGEND OF ZELDA'
Video: Initializing OpenGL Device Context.
Core: Setting 32-bit video mode: 640x480
Video Warning: Failed to set GL_SWAP_CONTROL to 0. (it's 1)
Video Warning: Failed to set GL_BUFFER_SIZE to 32. (it's 24)
Video Warning: Failed to set GL_DEPTH_SIZE to 16. (it's 24)
Video: Using OpenGL: GeForce GTX 460/PCIe/SSE2 - 4.6.0 NVIDIA 390.87 : NVIDIA Corporation
Audio: Using resampler src
[New Thread 0x7fffcb19e700 (LWP 17467)]
[New Thread 0x7fffca99d700 (LWP 17468)]
Audio: Initializing SDL audio subsystem...
[New Thread 0x7fffca19c700 (LWP 17469)]
Input: Rumble activated on N64 joystick #1
Input Warning: Couldn't open rumble support for joystick #2
Input Warning: Couldn't open rumble support for joystick #3
Input Warning: Couldn't open rumble support for joystick #4
Core: Initializing 4 RDRAM modules for a total of 8 MB
Core: Starting R4300 emulator: Dynamic Recompiler

Thread 1 "mupen64plus" received signal SIGFPE, Arithmetic exception.
0x00007fffce33d69a in FrameBufferManager::ComputeCImgHeight (this=0x498430, info=..., height=@0x7fffce3c9f20: 0)
    at ../../src/FrameBuffer.cpp:1147
1147	            height = ( g_dwRamSize - info.dwAddr ) / info.dwWidth;
(gdb) bt
#0  0x00007fffce33d69a in FrameBufferManager::ComputeCImgHeight (this=0x498430, info=..., height=@0x7fffce3c9f20: 0)
    at ../../src/FrameBuffer.cpp:1147
#1  0x00007fffce33dbc9 in FrameBufferManager::SetRenderTexture (this=0x498430) at ../../src/FrameBuffer.cpp:1271
#2  0x00007fffce33fe72 in FrameBufferManager::Set_CI_addr (this=0x498430, newCI=...) at ../../src/FrameBuffer.cpp:1802
#3  0x00007fffce370064 in DLParser_SetCImg (gfx=0x7fffced6f7d0) at ../../src/RSP_Parser.cpp:1545
#4  0x00007fffce370a07 in RDP_DLParser_Process () at ../../src/RSP_Parser.cpp:1702
#5  0x00007fffce3ace0b in ProcessRDPList () at ../../src/Video.cpp:848
#6  0x00007ffff7fa2978 in MT_CMD_END (rt=24) at ../..//su.c:166
#7  0x00007ffff7faa7d5 in COP0 (inst=1083721728) at ../..//su.c:1857
#8  0x00007ffff7faadd2 in run_task () at ../..//su.c:2054
#9  0x00007ffff7fb2039 in DoRspCycles (cycles=4294967295) at ../..//module.c:386
#10 0x00007fffef504248 in do_SP_Task (sp=0x7ffff44650b0 <g_dev+17832528>) at ../../src/device/rcp/rsp/rsp_core.c:278
#11 0x00007fffef503ec0 in update_sp_status (sp=0x7ffff44650b0 <g_dev+17832528>, w=293)
    at ../../src/device/rcp/rsp/rsp_core.c:159
#12 0x00007fffef5040df in write_rsp_regs (opaque=0x7ffff44650b0 <g_dev+17832528>, address=67371024, value=293, 
    mask=4294967295) at ../../src/device/rcp/rsp/rsp_core.c:224
#13 0x00007fffef500b12 in mem_write32 (handler=0x7ffff446b578 <g_dev+17858328>, address=67371024, value=293, 
    mask=4294967295) at ../../src/device/memory/memory.h:87
#14 0x00007fffef50132b in r4300_write_aligned_word (r4300=0x7ffff3363660 <g_dev>, address=67371024, value=293, 
    mask=4294967295) at ../../src/device/r4300/r4300_core.c:353
#15 0x00007fffef522240 in dynarec_write_aligned_word () at ../../src/device/r4300/recomp.c:957
#16 0x00007fffc8ee42e5 in ?? ()
#17 0x0400100000000003 in ?? ()
#18 0x00007fffcec1e010 in ?? ()
#19 0x0000000002000000 in ?? ()
#20 0x00007ffff3c63b48 in g_dev () from /usr/local/src/mupen64plus/install//lib/libmupen64plus.so.2
#21 0x00007fffef54ae3d in dyna_start () from /usr/local/src/mupen64plus/install//lib/libmupen64plus.so.2
#22 0x00007fffffffdd00 in ?? ()
#23 0x0000000000008000 in ?? ()
#24 0x000000000000003c in ?? ()
#25 0x0000000000000000 in ?? ()
(gdb) print info.dwWidth
$1 = 0
(gdb) f 3
#3  0x00007fffce370064 in DLParser_SetCImg (gfx=0x7fffced6f7d0) at ../../src/RSP_Parser.cpp:1545
1545	    g_pFrameBufferManager->Set_CI_addr(newCI);
(gdb) print newCI
$2 = {dwFormat = 7, dwSize = 3, dwWidth = 0, dwAddr = 16711680, bpl = 16384}
(gdb) print dwWidth
$3 = 4096

Troubleshooting further is beyond my understanding.

Core, UI, and plugins are compiled via:

INSTALL_STRIP_FLAG="" OPTFLAGS="" CFLAGS="-g3 -O0" make -C projects/unix/ -j16 PREFIX=/usr/local/src/mupen64plus/install install

Config file (renamed to .txt to satisfy github):

mupen64plus.cfg.txt

Thanks,
Corey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant