jkotlinski / lsdpack

Standalone LSDj recorder+player
GNU General Public License v2.0
116 stars 18 forks source link

segfault when dumping #27

Closed cyberic99 closed 1 year ago

cyberic99 commented 1 year ago

Hello

I tried to make a raw registers dump of a test song, I get a segfault

The provided .sav file has only one song I am using lsdj-4.7.3

command:

lsdpack -r -d lsdj.gb

I get a crash, here is the backtrace from gdb:

#0  0x00007ffff7aa149c in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff7a51958 in raise () from /usr/lib/libc.so.6
#2  0x00007ffff7a3b53d in abort () from /usr/lib/libc.so.6
#3  0x00007ffff7a9563e in ?? () from /usr/lib/libc.so.6
#4  0x00007ffff7aab22c in ?? () from /usr/lib/libc.so.6
#5  0x00007ffff7aad07c in ?? () from /usr/lib/libc.so.6
#6  0x00007ffff7aaf9f3 in free () from /usr/lib/libc.so.6
#7  0x00007ffff7a99ae6 in _IO_default_finish () from /usr/lib/libc.so.6
#8  0x00007ffff7a8b905 in fclose () from /usr/lib/libc.so.6
#9  0x0000555555582a2e in DumpWriter::record_song_stop() ()
#10 0x0000555555581a6d in on_ff_write(char, char, unsigned long) ()
#11 0x00005555555a3f9c in gambatte::Memory::nontrivial_ff_write(unsigned int, unsigned int, unsigned long) ()
#12 0x000055555559b86c in gambatte::Memory::ff_write(unsigned int, unsigned int, unsigned long) ()
#13 0x000055555559a4fe in gambatte::CPU::process(unsigned long) ()
#14 0x000055555558f001 in gambatte::CPU::runFor(unsigned long) ()
#15 0x000055555559c5ac in gambatte::GB::runFor(unsigned int*, long, unsigned int*, unsigned long&) ()
#16 0x00005555555816b2 in run_one_frame() ()
#17 0x00005555555816e6 in wait(float) ()
#18 0x00005555555819b5 in play_song() ()
#19 0x0000555555582474 in record_dump(int, char**, bool) ()
#20 0x00005555555826af in main ()

what is surprising is that the .sav file should only contain one song. or is it corrupted somehow ?

And when using the -g option, I get:

lsdpack -g lsdj.gb
.gbs mode enabled
Loaded lsdj.gb
Playing song 1...
Recording to 'lsdj-1.s'
Wrote 16 samples
Song 1: 3311 bytes
Playing song 2...
Recording to 'lsdj-2.s'
Wrote 16 samples
Song 1: 3318 bytes
Playing song 3...
Recording to 'lsdj-3.s'
Wrote 16 samples
Song 1: 3313 bytes
Playing song 4...
Recording to 'lsdj-4.s'
Wrote 16 samples
Song 1: 3313 bytes
Playing song 5...
Recording to 'lsdj-5.s'
Wrote 0 samples
Playing song 6...
Recording to 'lsdj-6.s'
Wrote 0 samples
Playing song 7...
Recording to 'lsdj-7.s'
Wrote 0 samples
Playing song 8...
Recording to 'lsdj-8.s'
Wrote 0 samples
Playing song 9...
Recording to 'lsdj-9.s'
Wrote 0 samples
Playing song 10...
Recording to 'lsdj-10.s'
Wrote 0 samples
Playing song 11...
Recording to 'lsdj-11.s'
Wrote 0 samples
Playing song 12...
Recording to 'lsdj-12.s'
Wrote 0 samples
Playing song 13...
Recording to 'lsdj-13.s'
Wrote 0 samples
Playing song 14...
Recording to 'lsdj-14.s'
Wrote 0 samples
Playing song 15...
Recording to 'lsdj-15.s'
Wrote 0 samples
Playing song 16...
Recording to 'lsdj-16.s'
Wrote 0 samples
Playing song 17...
Recording to 'lsdj-17.s'
Wrote 0 samples
Playing song 18...
Recording to 'lsdj-18.s'
Wrote 0 samples
Playing song 19...
Recording to 'lsdj-19.s'
Wrote 0 samples
Playing song 20...
Recording to 'lsdj-20.s'
Wrote 0 samples
Playing song 21...
Recording to 'lsdj-21.s'
Wrote 0 samples
Playing song 22...
Recording to 'lsdj-22.s'
Wrote 0 samples
Playing song 23...
Recording to 'lsdj-23.s'
Wrote 0 samples
Playing song 24...
Recording to 'lsdj-24.s'
Wrote 0 samples
Playing song 25...
Recording to 'lsdj-25.s'
Wrote 0 samples
Playing song 26...
Recording to 'lsdj-26.s'
Wrote 0 samples
Playing song 27...
Recording to 'lsdj-27.s'
Wrote 0 samples
Playing song 28...
Recording to 'lsdj-28.s'
Wrote 0 samples
Playing song 29...
Recording to 'lsdj-29.s'
Wrote 0 samples
Playing song 30...
Recording to 'lsdj-30.s'
Wrote 0 samples
Playing song 31...
Recording to 'lsdj-31.s'
Wrote 0 samples
Playing song 32...
Recording to 'lsdj-32.s'
Wrote 0 samples
OK

PS: previously I already successfully converted some songs using the same LSDJ version, so at some point, it was working (maybe with an older version of lsdpack)

I'm attaching lsdj.gb and lsdj.sav below.

lsdj.zip

Thank you !

jkotlinski commented 1 year ago

The attached ROM image is patched with LittleFM. LittleFM is not supported.

jkotlinski commented 1 year ago

Could you tell if this change fixes the crash problem? 7e0d481a172ec6b8bd6553e4684f64590cc1a44f

cyberic99 commented 1 year ago

The attached ROM image is patched with LittleFM. LittleFM is not supported.

oh really ?

At some point it was supported, I had added some tweaks myself

Even the changelog says '- Support ROM images patched with LittleFM.'

Could you tell if this change fixes the crash problem? https://github.com/jkotlinski/lsdpack/commit/7e0d481a172ec6b8bd6553e4684f64590cc1a44f

Yes, the crash problem is fixed. this is the output I get now:

register dump mode enabled
recording using emulated DMG
Loaded lsdj.gb
Playing song 1...
Recording to 'lsdj-1.txt'
Playing song 2...
Recording to 'lsdj-2.txt'
Playing song 3...
Recording to 'lsdj-3.txt'
Playing song 4...
Recording to 'lsdj-4.txt'
Playing song 5...
Recording to 'lsdj-5.txt'
Aborted: Song did not start.

But the .sav contains only one song so I'm not sure what is dumped to songs 2-5

Thanks

jkotlinski commented 1 year ago

Ah, you are right, I forgot!

OK, I found the problem, here is a proper fix: 463036a

cyberic99 commented 1 year ago

Yes ! The latest commit fixes the issue, and also works with a ROM patched with LittleFM.

Thank you very much for your time and your reactivity.

And for LSDj !

jkotlinski commented 1 year ago

Great, thank you for confirming!

On Thu, 27 Oct 2022 at 09:39, cyberic99 @.***> wrote:

Yes ! The latest commit fixes the issue, and also works with a ROM patched with LittleFM.

Thank you very much for your time and your reactivity.

And for LSDj !

— Reply to this email directly, view it on GitHub https://github.com/jkotlinski/lsdpack/issues/27#issuecomment-1293118404, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY34O7FPQC64MIVXAJR36LWFIWSZANCNFSM6AAAAAARKUHRUE . You are receiving this because you commented.Message ID: @.***>

cyberic99 commented 1 year ago

hey @jkotlinski it seems this issue can be closed, as it appears to be fixed

jkotlinski commented 1 year ago

ok, thank you!