Hi there. I have very strange behaviour with emscripten version of dosbox-x.
I use exactly same codebase for PC and browser. But they are behave differently.
For example I have this simple DOS program:
#include <conio.h>
void main (int argc, char *argv[]) {
printf("%.2f\n", (double) 1000);
}
I compile it for dos, and run it with dosbox-x in browser and PC.
The PC output is 1000.00, but the browser output is 0.00.
The weirdest thing is that this only happens with printf and %.2f, I tried David M. Gay's 'dtoa()' function to print the doubles
manually and it works exactly the same under dosbox-x in browser and PC.
Asan, UBsan and valgrind does not see any errors in the code when I run it on PC.
I build dosbox-x with stacksize = 1Mb, and I found that if I restore default value it start failing randomly.
But error is always "unrechable executed" and not related to stacksize.
I tried Asan, UBsan for borwser build, and they are totaly ueseless they always end with same "unreachable executed" in same funcitons as a build without it.
-s SAFE_HEAP=1/2 -sASSERTIONS=1 also end with "unreachable executed" in same functions.
I also tried -O1,O2 builds, nothing changed. I can't run -O0 because of the browser's local limits.
The typical error stack is:
ncaught RuntimeError: unreachable
at DOS_Device::Write(unsigned char const*, unsigned short*) (0505c02e:0xb04ce3)
at DOS_WriteFile(unsigned short, unsigned char const*, unsigned short*, bool) (0505c02e:0x1bc6a)
at Program::WriteOut(char const*, ...) (0505c02e:0x9850)
at showWelcome(Program*) (0505c02e:0x3a8372)
at DOS_Shell::Prepare() (0505c02e:0xad20b5)
at SHELL_Run() (0505c02e:0x95461e)
at BIOS::cb_bios_boot__func() (0505c02e:0xc2be24)
at Normal_Loop() (0505c02e:0x9b4470)
at DOSBOX_RunMachine() (0505c02e:0xd3a9c)
at jsdos_main(Config*) (0505c02e:0x7a3261)
$DOS_Device::Write(unsigned char const*, unsigned short*) @ 0505c02e:0xb04ce3
$DOS_WriteFile(unsigned short, unsigned char const*, unsigned short*, bool) @ 0505c02e:0x1bc6a
$Program::WriteOut(char const*, ...) @ 0505c02e:0x9850
$showWelcome(Program*) @ 0505c02e:0x3a8372
$DOS_Shell::Prepare() @ 0505c02e:0xad20b5
$SHELL_Run() @ 0505c02e:0x95461e
$BIOS::cb_bios_boot__func() @ 0505c02e:0xc2be24
$Normal_Loop() @ 0505c02e:0x9b4470
$DOSBOX_RunMachine() @ 0505c02e:0xd3a9c
$jsdos_main(Config*) @ 0505c02e:0x7a3261
$server_run() @ 0505c02e:0x75a157
$runRuntime @ 0505c02e:0x75edbf
ret.<computed> @ 7218a4e8-6c38-4c3c-9e76-65c481c94470:8
doRewind @ 7218a4e8-6c38-4c3c-9e76-65c481c94470:8
(anonymous) @ 7218a4e8-6c38-4c3c-9e76-65c481c94470:8
Module.receive @ 7218a4e8-6c38-4c3c-9e76-65c481c94470:8