Page 1 of 1

430/VX with AWE32 crashes emulator on start

Posted: Tue 13 Feb, 2018 5:05 pm
by misterj88
Hi there,

I have just built commit c16ab21 using MSYS2. Initially everything looks good, but I have found when trying to start a 430/VX machine that the emulator crashes before even the BIOS screen loads. The common link seems to be the AWE32 sound card - if I remove this it will boot. My ROM files are ok on v13.1 so not sure if this is something I've done, or something in the code that needs looking into.

If I can supply anything to help (NVR file, build details, etc.) please let me know.

Thanks!

James

Re: 430/VX with AWE32 crashes emulator on start

Posted: Tue 13 Feb, 2018 5:50 pm
by SarahWalker
Could you post the config file you're using please?

Re: 430/VX with AWE32 crashes emulator on start

Posted: Tue 13 Feb, 2018 9:15 pm
by shermanp
This looks like it could be an MSYS2 problem. Or maybe the specific libraries used.

I did a fresh recompile with MSYS2, and got the same problem. (Crashes with SB16, but doesn't with no sound card)

I then dusted off my TDM-GCC-32 installation and compiled PCem. It starts without any issue at all, using the same config file. (and wow, is MSYS2 compilation slow by comparison!)

Re: 430/VX with AWE32 crashes emulator on start

Posted: Tue 13 Feb, 2018 9:44 pm
by JosepMa
Will try now with a debug build, but so far, I've got this.

Thread 33 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 12632.0x2948]
0x005bb0ea in sb_get_buffer_emu8k ()
(gdb) bt
#0 0x005bb0ea in sb_get_buffer_emu8k ()
#1 0x0057bce4 in sound_poll ()
#2 0x005c4ebf in timer_process ()
#3 0x00483532 in exec386_dynarec ()
#4 0x0055f5c5 in runpc ()
#5 0x0067e4a9 in mainthread ()
#6 0x6c991bd8 in ?? () from D:\msys64\mingw32\bin\SDL2.dll
#7 0x6c9e558e in ?? () from D:\msys64\mingw32\bin\SDL2.dll
#8 0x769f67f1 in msvcrt!_beginthreadex () from C:\WINDOWS\System32\msvcrt.dll
#9 0x769f68b1 in msvcrt!_endthreadex () from C:\WINDOWS\System32\msvcrt.dll
#10 0x73ab8654 in KERNEL32!BaseThreadInitThunk ()
from C:\WINDOWS\System32\kernel32.dll
#11 0x76f84a77 in ntdll!RtlGetAppContainerNamedObjectPath ()
from C:\WINDOWS\SYSTEM32\ntdll.dll
#12 0x76f84a47 in ntdll!RtlGetAppContainerNamedObjectPath ()
from C:\WINDOWS\SYSTEM32\ntdll.dll
#13 0x00000000 in ?? ()



EDIT: In debug it doesn't crash, but the release backtrace might indicate that the changes for the dynamic filter are the culprit.
I don't quite like the fact of using a static local variable, and also, the filter coefficients are not initialized at startup, only when the card is configured by an application, but at that time, the audio buffer is already running.

EDIT2: Should I mention that the "pos" variable should also be "per channel"?

EDIT3: Aside of the crash, the implementation of the filter is definitely broken. Printing the coeffs for frequency 45454 gives this result:
I'll take a look and try to fix, if yo don't do that faster than me.

Code: Select all

1:      0.000014
2:      -0.000051
3:      0.000097
4:      -0.000131
5:      0.000122
6:      -0.000025
7:      -0.000216
8:      0.000672
9:      -0.001422
10:     0.002551
11:     -0.004144
12:     0.006269
13:     -0.008975
14:     0.012278
15:     -0.016153
16:     0.020528
17:     -0.025284
18:     0.030256
19:     -0.035240
20:     0.040011
21:     -0.044331
22:     0.047971
23:     -0.050732
24:     0.052456
25:     0.946958
26:     0.052456
27:     -0.050732
28:     0.047971
29:     -0.044331
30:     0.040011
31:     -0.035240
32:     0.030256
33:     -0.025284
34:     0.020528
35:     -0.016153
36:     0.012278
37:     -0.008975
38:     0.006269
39:     -0.004144
40:     0.002551
41:     -0.001422
42:     0.000672
43:     -0.000216
44:     -0.000025
45:     0.000122
46:     -0.000131
47:     0.000097
48:     -0.000051
49:     0.000014
50:     0.000000

Re: 430/VX with AWE32 crashes emulator on start

Posted: Tue 13 Feb, 2018 9:54 pm
by jznomoney
commit c68d358 is when the issue occurs.

Re: 430/VX with AWE32 crashes emulator on start

Posted: Tue 13 Feb, 2018 11:34 pm
by JosepMa
As a temporary patch for the crash, you can use this patch.

Currently the startup process is full of blips until the soundcard is correctly initialized by the drivers or an application, so more works needs to be done for a full fix.

Re: 430/VX with AWE32 crashes emulator on start

Posted: Wed 14 Feb, 2018 10:12 am
by misterj88
Hi all,

Wow - only just returned to this thread! I can confirm that the 'fix-crash-sb16-newfilter.patch' when applied to commit c16ab21 and rebuilt in my MSYS2 environment now no longer crashes on start up. Amazing fast work!

I can hear a rhythmic popping through my speakers as the BIOS loads and progresses to boot from disk so there is something not quite clean with the sound card, but the original crash has gone. Not sure if I can contribute as fast or as comprehensively as you guys work but if I can do anything, even just to test patches or builds I'm more than happy to do so.

Re: 430/VX with AWE32 crashes emulator on start

Posted: Wed 14 Feb, 2018 10:13 am
by misterj88
SarahWalker wrote:
Tue 13 Feb, 2018 5:50 pm
Could you post the config file you're using please?
In case it's still useful, please find attached. Thank you!

Re: 430/VX with AWE32 crashes emulator on start

Posted: Wed 14 Feb, 2018 6:00 pm
by SarahWalker
Rev 1037 fixes the out-of-bounds access that I believe was causing the crash. Rev 1038 initialises the filter to something sensible on emulator startup.

Re: 430/VX with AWE32 crashes emulator on start

Posted: Wed 14 Feb, 2018 6:01 pm
by SarahWalker
JosepMa wrote:
Tue 13 Feb, 2018 9:44 pm
EDIT3: Aside of the crash, the implementation of the filter is definitely broken. Printing the coeffs for frequency 45454 gives this result:
I'll take a look and try to fix, if yo don't do that faster than me.
Could you explain what exactly is broken about it? It looks (and sounds) okay to me.

Re: 430/VX with AWE32 crashes emulator on start

Posted: Wed 14 Feb, 2018 9:49 pm
by JosepMa
@Sarah:
First, apologies about the "Edit 2". I overlooked the "if" that controls that pos gets incremented only when the last channel has been processed.

About "edit 3", I believe I just got fooled by the lack of precision.
As it can be seen in the images i attach, the dots don't really represent the sinc function (I haven't placed them 100% correctly, but I wanted to show that looking just at the dots, one cannot extrapolate that such is a windowed sinc).
I will do some more tests, and see if maybe it shouldn't be sinc(2.0 *...) but rather sinc( ...)

EDIT: Ok, nevermind.. now I realize that what I see in the graph is the consequence of filtering 45Khz at 48Khz. (the fC constants is ~0.47 , and at 0.25 it looks like what I was describing above, and of course, that would filter the sound rather than let it pass unfiltered)


I implemented a sinc resampler several years ago in Psycle (https://sourceforge.net/p/psycle/code/ currently sourceforge is in maintenance mode), although a sinc filter is something slightly different.



Btw, what is your view about using intrinsics in Pcem?
https://software.intel.com/sites/landin ... sicsGuide/#

Re: 430/VX with AWE32 crashes emulator on start

Posted: Wed 14 Feb, 2018 10:16 pm
by SarahWalker
JosepMa wrote:
Wed 14 Feb, 2018 9:49 pm
Btw, what is your view about using intrinsics in Pcem?
https://software.intel.com/sites/landin ... sicsGuide/#
Fine as long as there's a fallback for when not building for x86 - that's not a reality currently but I do want to make PCem more portable for v15. I'd also request that you stick to SSE2.