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

System is deadlocked on memory -- Tinycore Linux 11 in browser (WASM) #2

Closed
ARyaskov opened this issue Mar 16, 2020 · 6 comments
Closed

Comments

@ARyaskov
Copy link

Hi!

First of all, thank you for really amazing project!

Trying to boot TinyCore Linux 11 (http://tinycorelinux.net/) in browser (WASM)

and get System is deadlocked on memory error (see attached screenshot).

tc11_fail

Compiled with node makefile.js emscripten release --enable-wasm
Emscripten info: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.39.9, clang version 11.0.0 MacOS

Run in Chrome 80 via serve npm package (via http://localhost:5000/?cda=tc11os)

I think the system is out of memory -- how can I increase available RAM for OS (e.g. via browser address line parameters?)?

Thank you!

@nepx
Copy link
Owner

nepx commented Mar 16, 2020

Hi,

The mem parameter controls the amount of emulated RAM (i.e. http://localhost:8080/index.html?cda=tinycore&mem=128 for 128 MB of RAM). Some options are in runtime.js

TinyCore Linux won't boot because of some problems with ATAPI sector caching. I think it's the same bug that makes Ubuntu crash if it's booted with a CD-ROM attached.

Browser stack trace:

Error: abort(undefined). Build with -s ASSERTIONS=1 for more info.
abort@http://localhost:8080/halfix.js:84259:9
_abort@http://localhost:8080/halfix.js:86680:7
util_abort@http://localhost:8080/halfix.js:82401:2
ide_atapi_read@http://localhost:8080/halfix.js:68074:2
ide_pio_read_callback@http://localhost:8080/halfix.js:46805:22
ide_pio_readd@http://localhost:8080/halfix.js:66650:24
insd32@http://localhost:8080/halfix.js:61758:66
op_insd32@http://localhost:8080/halfix.js:80372:7
cpu_execute@http://localhost:8080/halfix.js:80515:44
cpu_run@http://localhost:8080/halfix.js:65216:4
pc_execute@http://localhost:8080/halfix.js:60772:8
emscripten_run@http://localhost:8080/halfix.js:82127:7
Module._emscripten_run@http://localhost:8080/halfix.js:87101:42
run_wrapper@http://localhost:8080/runtime.js:544:21

Browser message:

[IDE] Error trying to fetch already-fetched ATAPI data

Native log:

[I/O] readb: port=0x03f6 res=0x58
[I/O] readb: port=0x01f1 res=0x00
[I/O] readb: port=0x01f2 res=0x02
[I/O] readb: port=0x01f3 res=0x00
[I/O] readb: port=0x01f4 res=0x00
[I/O] readb: port=0x01f5 res=0x10
[I/O] readb: port=0x01f6 res=0xa0
[IDE] Reading sector 9727 - 2 left - frame 2048/4096 [res: 2048], sectsize=2048
[IDE] pio length: 2048
[IDE] Finished current frame : str=1 btt=2048 50
[PIC] Raising IRQ 14
[APIC] Received bus message: vector=22 type=0 trigger=0
[IDE]    atapi read sector=9728
Unable to read 512 bytes from image file

nepx added a commit that referenced this issue Mar 17, 2020
The formula total_sectors - lba + 1 calculates one sector too many
nepx added a commit that referenced this issue Mar 18, 2020
Cross-sector ATAPI reads were problematic because we determined how many bytes of the previous frame to save based on the transfer count. This led to cases where the first few bytes of the sector would be read-read under certain circumstances.
Now we determine how many bytes to save based on the total bytes transferred. This fixes TinyCore Linux and allows it to boot to desktop.
@nepx
Copy link
Owner

nepx commented Mar 20, 2020

With the latest commits TinyCore Linux boots, and the mouse works. I found that 64 MB of RAM and 4 MB of VGA RAM works well.

TinyCore Linux

For some reason, the desktop icons don't render in the WebAssembly version, but you can still open the terminal and a few other apps by bringing the right-click menu.

@nepx nepx closed this as completed Mar 20, 2020
@ARyaskov
Copy link
Author

Hi, sorry for late reply!
Thank you very much for fixes have been done!
I've recompiled Halfix from latest commit.
But I'm still no reach my goal -- run any modern Linux-based OS (with v3 or v4 kernel) in browser relatively smoothly (it's not possible to run it in browser at full speed at the moment of course :) ), not in a native app.

Here is my journey for run various OSes in browser wasm (node makefile.js emscripten --enable-wasm release):

dsl-4.11.rc2 from cd

index.html?cda=dsl-4.11.rc2&mem=256

Screenshot 2020-04-08 at 18 05 57

tinycore from v3 to v11 from cd (booting in command-line only mode)

index.html?cda=tcos&mem=128

does not work

while booting the kernel stage:

RuntimeError: abort(undefined) at Error at jsStackTrace (http://localhost:5001/halfix.js:1:21255) at stackTrace (http://localhost:5001/halfix.js:1:21423) at abort (http://localhost:5001/halfix.js:1:16864) at _abort (http://localhost:5001/halfix.js:1:76158) at wasm-function[28]:0x1cf8 at wasm-function[112]:0xf040 at wasm-function[1152]:0x6b15f at wasm-function[349]:0x48b8a at wasm-function[391]:0x4cb7f at wasm-function[865]:0x5f9e4 RuntimeError: abort(undefined) at Error at jsStackTrace (http://localhost:5001/halfix.js:1:21255) at stackTrace (http://localhost:5001/halfix.js:1:21423) at abort (http://localhost:5001/halfix.js:1:16864) at _abort (http://localhost:5001/halfix.js:1:76158) at wasm-function[28]:0x1cf8 at wasm-function[112]:0xf040 at wasm-function[1152]:0x6b15f at wasm-function[349]:0x48b8a at wasm-function[391]:0x4cb7f at wasm-function[865]:0x5f9e4 at abort (http://localhost:5001/halfix.js:1:16895) at _abort (http://localhost:5001/halfix.js:1:76158) at wasm-function[28]:0x1cf8 at wasm-function[112]:0xf040 at wasm-function[1152]:0x6b15f at wasm-function[349]:0x48b8a at wasm-function[391]:0x4cb7f at wasm-function[865]:0x5f9e4 at wasm-function[324]:0x44a5d at wasm-function[470]:0x4f25a

tinycore v2 from cd

🔥 works, load bash, successfully execute any terminal command, but it has old 2.6 kernel

slitaz 4 linux base live from cd

while booting:

(yes, this trace quite useless, but jfyi)

RuntimeError: abort(undefined) at Error at jsStackTrace (http://localhost:5001/halfix.js:1:21255) at stackTrace (http://localhost:5001/halfix.js:1:21423) at abort (http://localhost:5001/halfix.js:1:16864) at _abort (http://localhost:5001/halfix.js:1:76158) at wasm-function[28]:0x1cf8 at wasm-function[112]:0xf040 at wasm-function[1152]:0x6b15f at wasm-function[349]:0x48b8a at wasm-function[391]:0x4cb7f at wasm-function[865]:0x5f9e4 RuntimeError: abort(undefined) at Error at jsStackTrace (http://localhost:5001/halfix.js:1:21255) at stackTrace (http://localhost:5001/halfix.js:1:21423) at abort (http://localhost:5001/halfix.js:1:16864) at _abort (http://localhost:5001/halfix.js:1:76158) at wasm-function[28]:0x1cf8 at wasm-function[112]:0xf040 at wasm-function[1152]:0x6b15f at wasm-function[349]:0x48b8a at wasm-function[391]:0x4cb7f at wasm-function[865]:0x5f9e4 at abort (http://localhost:5001/halfix.js:1:16895) at _abort (http://localhost:5001/halfix.js:1:76158) at wasm-function[28]:0x1cf8 at wasm-function[112]:0xf040 at wasm-function[1152]:0x6b15f at wasm-function[349]:0x48b8a at wasm-function[391]:0x4cb7f at wasm-function[865]:0x5f9e4 at wasm-function[324]:0x44a5d at wasm-function[470]:0x4f25a

alpine linux 3.3.3 x86 from cd

index.html?cda=alpine-3.3.3-x86&mem=256

while booting:

RuntimeError: function signature mismatch at wasm-function[865]:0x5f9e4 at wasm-function[324]:0x44a5d at wasm-function[470]:0x4f25a at wasm-function[536]:0x519a4 at Module._emscripten_run (http://localhost:5001/halfix.js:1:86980) at run_wrapper (http://localhost:5001/runtime.js:544:21) runtime.js:562 Uncaught RuntimeError: function signature mismatch at wasm-function[865]:0x5f9e4 at wasm-function[324]:0x44a5d at wasm-function[470]:0x4f25a at wasm-function[536]:0x519a4 at Module._emscripten_run (http://localhost:5001/halfix.js:1:86980) at run_wrapper (http://localhost:5001/runtime.js:544:21)

ReactOS-0.4.12 from cd

/index.html?cda=ReactOS-0.4.12&mem=512

Enter into setup mode, failed while 'Select HardDrive for install' stage (No harddrives are available)

FreeDOS 1.2 from hd (preinstalled with qemu https://github.com/palmercluff/qemu-images/tree/master/freedos-1.2)

🔥 boots and it's possible to run any command in command line

KolibriOS 0 7 4 from hd (preinstalled with qemu https://github.com/palmercluff/qemu-images/tree/master/test-images/kolibri-os)

🔥 works with GUI, but very slowly (about 5 seconds for its notepad version opening)

MenuetOS preinstalled with qemu

Hangs while booting (I can not enter any number from keyboard in order to specify
the variant of OS loading, pressed keys got no response from OS)

nepx added a commit that referenced this issue Apr 27, 2020
…t in browser (#2)

Not enough bytes were being prefetched, which posed an issue during cross-block loads
@nepx
Copy link
Owner

nepx commented Apr 27, 2020

@ARyaskov MenuetOS (from the original floppy disk) seems to work fine, I downloaded the floppy from M32-086B.ZIP and it runs perfectly. A recent commit has fixed floppy drive emulation in the browser.

http://localhost:8080/halfix/index.html?fda=disks/menuet&mem=64

Screenshot_2020-04-27 Halfix x86 Emulator -  800 x 600  - Press ESC to release mouse

During boot, I chose 24 BPP 800x600, use preset, no MTRR accleration, PS/2 mouse, 64 MB RAM, and image from floppy.

Screenshot_2020-04-27 Halfix x86 Emulator -  720 x 400  - Press ESC to release mouse

Thanks for the bug reports, they're helping me fix a lot of issues.

@nepx
Copy link
Owner

nepx commented Apr 27, 2020

ReactOS LiveCD works well in the browser.

http://localhost:8080/home/jkim13/Desktop/halfix/index.html?cda=disks/reactos&mem=128

Screenshot_2020-04-27 Halfix x86 Emulator -  640 x 480  - Press ESC to release mouse

There are some VGA glitches (no icons), but they happen on the native version too. They go away if you enable PCI VGA.

I haven't tried installing it, but it should work, in theory, if you attach a blank hard drive image (http://localhost:8080/halfix/index.html?cda=reactos&hdb=300Mempty. All the changes to the image will be erased on the next page refresh, however.

nepx added a commit that referenced this issue Apr 27, 2020
This allows ReactOS to use the nice big VESA screen
@nepx
Copy link
Owner

nepx commented May 24, 2020

Somewhere in the last few commits, major bugs preventing TinyCore and Damn Small Linux from booting in the browser have been fixed. I'm not sure how exactly I fixed these bugs, but I guess that all that matters is that they're gone.

Anyways, I revamped index.html by making it prettier and easier to configure. If you know of any other operating systems that don't work, please let me know.

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

2 participants