bsnes 0.037a segfaults upon rom load (linux i386)

Archived bsnes development news, feature requests and bug reports. Forum is now located at http://board.byuu.org/
Locked
belegdol
Hazed
Posts: 68
Joined: Tue Dec 07, 2004 10:24 am

bsnes 0.037a segfaults upon rom load (linux i386)

Post by belegdol »

Hi, this seems to occur only for i386 builds, since x86_64 ones do work fine. ThBacktrace I was able to get seems really short:
(gdb) bt
#0 0xf0d1f020 in ?? ()
#1 0x080adee7 in Scheduler::sync_cpusmp () at snes/scheduler/scheduler.h:30
#2 sCPU::mmio_write (this=0x81c1000, addr=8512, data=0 '\0')
at cpu/scpu/mmio/mmio.cpp:482
Backtrace stopped: frame did not save the PC
(gdb)
There is longer one available in the review request.
byuu

Post by byuu »

Lots of odd things on that page.

First, the zlib patch shouldn't be needed for Linux. It converts filenames to UTF-16 before opening them, but only on Windows. Linux is UTF-8 native.

Second, I don't think ZSNES uses BGR15 internal mode. So you probably won't be able to use the system snes_ntsc library.

I don't get the zeal to make everything a system library, personally. I understand the "we can fix bugs in the libs without updating the main binary" part -- but these are only ~100kb libs, and it's just as likely that future lib updates will retro-actively break the program anyway. But ... if you want those two separate, that's fine by me I guess.

$(strip) is just a function to remove excess whitespace (" _A_ _B_ " -> "A B") from strings. It makes the console compilation output slightly prettier. It strips binaries through the -s flag passed to the linker.

As for your crash, not that I'm upset -- but this is why you shouldn't randomly modify others' makefiles :P

sed -i "s#flags = -O3 -fomit-frame-pointer#flags = %{optflags}#" src/Makefile

Most likely, %{optflags} does not contain -fomit-frame-pointer, which is needed for libco's co_switch() function to work properly. It's a GCC issue (it adds code even to 'naked' functions when the frame pointer is enabled), only other way around that is to go back to assembling libco with yasm.
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

byuu wrote:It's a GCC issue (it adds code even to 'naked' functions when the frame pointer is enabled)
Sorry for this somewhat off-topic question, but how do you get naked functions in GCC? Everything I found when I was looking into this a while ago said the compiler tries to determine on its own whether or not to include prolog and epilog code.. which consistently failed when I tried to make assembly-only functions. Does using -fomit-frame-pointer fix this? (I'd still prefer to have MSVC's __declspec(naked) rather than rely on compiler magic, but..)
belegdol
Hazed
Posts: 68
Joined: Tue Dec 07, 2004 10:24 am

Post by belegdol »

byuu wrote:Lots of odd things on that page.

First, the zlib patch shouldn't be needed for Linux. It converts filenames to UTF-16 before opening them, but only on Windows. Linux is UTF-8 native.
OK, I'll re-add the zlib patch then.
byuu wrote:Second, I don't think ZSNES uses BGR15 internal mode. So you probably won't be able to use the system snes_ntsc library.
Using system snes_ntsc was abandoned.
byuu wrote:I don't get the zeal to make everything a system library, personally. I understand the "we can fix bugs in the libs without updating the main binary" part -- but these are only ~100kb libs, and it's just as likely that future lib updates will retro-actively break the program anyway. But ... if you want those two separate, that's fine by me I guess.
I don't get the zeal either, especially when it requires excessive amounts of work :)
byuu wrote:$(strip) is just a function to remove excess whitespace (" _A_ _B_ " -> "A B") from strings. It makes the console compilation output slightly prettier. It strips binaries through the -s flag passed to the linker.
Oh, so strip can stay, and to have a working debuginfo I only need to get rid of -s?
byuu wrote:As for your crash, not that I'm upset -- but this is why you shouldn't randomly modify others' makefiles :P

sed -i "s#flags = -O3 -fomit-frame-pointer#flags = %{optflags}#" src/Makefile

Most likely, %{optflags} does not contain -fomit-frame-pointer, which is needed for libco's co_switch() function to work properly. It's a GCC issue (it adds code even to 'naked' functions when the frame pointer is enabled), only other way around that is to go back to assembling libco with yasm.
OK, I'll keep -fomit-frame-pointer then.
byuu

Post by byuu »

how do you get naked functions in GCC?
There's no __attribute__ for it, sadly. For Linux, you need -fomit-frame-pointer, for OS X I believe you need -static or something like that in addition to. You'd have to check with Lucas or Vas. It ends up having the same effect, and since the code isn't portable anyway ...

I do wish there were a way I could detect frame pointer mode and at least give a compiler warning.
Oh, so strip can stay, and to have a working debuginfo I only need to get rid of -s?
Yeah, replace -s with -g, IIRC.
Locked