nifanfa / MOOS

C# x64 operating system programming with the .NET native ahead-of-time compilation technology.
https://github.com/nifanfa/MOOS/wiki
The Unlicense
1.02k stars 83 forks source link

Bare metal Freeze/Crash at Native.Sti() call in ThreadPool.Initialize #71

Closed ayesaac closed 1 year ago

ayesaac commented 1 year ago

Running on an I7 6700K bare metal, OS freezes/crashes without any output at Native.Sti() call in ThreadPool.Initialize()

https://github.com/nifanfa/MOOS/blob/10737deb70ce82fe731a3debad1de298df8e47b1/Kernel/Misc/Threading.cs#L145

Same ISO works fine in QEMU, Can try to extract more information with WriteLines prior if it'd be at all helpful 😅

Console.WriteLine before and after the call in question, output looks like:

IMG_20221210_015439008.jpg

Happens with GC & GUI disabled, or enabled. Both work in VM. APIC build var can't be disabled without code changes; Timer and presumably other stuff uses it without compiler ifs.

ayesaac commented 1 year ago

Same issue on i7 Thinkpad x230

IMG_20221210_020257684.jpg

Also confirmed that everything but Threadpool (and SMP) works; can initialize everything else, and at least read/write from/to console in a loop.

nifanfa commented 1 year ago

Does it just freeze or get panic information?

nifanfa commented 1 year ago

Oh @iBeizsley

nifanfa commented 1 year ago

Try not initialize sata controller

nifanfa commented 1 year ago

https://github.com/nifanfa/MOOS/blob/10737deb70ce82fe731a3debad1de298df8e47b1/Kernel/Misc/EntryPoint.cs#L79

nifanfa commented 1 year ago

i remember sata controller have some problems

ayesaac commented 1 year ago

Just freezes, no panic. Disabling SATA didn't work, went ahead and tried with Keyboard, Serial, PS2, VMware tools, SMBIOS, PCI, IDE and SATA all disabled, same result:

IMG_20221213_033539627.jpg

Just for clarity, writeline before the Native.Sti being the last thing here, there's a second writeline immediately after, before Schedule_Next, not getting hit.

nifanfa commented 1 year ago

try not initialize threadpool and smp and see if it works

nifanfa commented 1 year ago

i'll check it as soon as possible

nifanfa commented 1 year ago

just make sure it is a problem of threadpool

nifanfa commented 1 year ago

20221214_104333_HDR

nifanfa commented 1 year ago

yeah i got the same problem

nifanfa commented 1 year ago

so the problem looks like the trampoline address

nifanfa commented 1 year ago

@iBeizsley

nifanfa commented 1 year ago

no the problem is ThreadPool for sure

nifanfa commented 1 year ago

https://github.com/nifanfa/MOOS/tree/main I just reverted the newest changes. you can use this one

nifanfa commented 1 year ago

it works fine on real hardware

nifanfa commented 1 year ago

20221214_202157

nifanfa commented 1 year ago

The problem might be with native aot itself. We can't make Corlib a lib instead of shared project

nifanfa commented 1 year ago

So the problem is solved

nifanfa commented 1 year ago

i just renamed stable to main btw

nifanfa commented 1 year ago

let me know if it works now

nifanfa commented 1 year ago

I found that the real problem is that ILCompiler is not stable