On Fri, May 26, 2023 at 7:22 PM Samuel Thibault <samuel.thiba...@gnu.org> wrote:
> I.e. gnumach without optimizations gets things wrong. We do want to fix
> that :)

Dumping what I've been able to debug (so far):

The crash indeed happens when loading the executable image, inside
copyout (). The addresses/sizes are all fine, that's a false lead.

What's apparently important here is that it's copying to the memory
just vm_allocated inside the task's own map, and as always the page
gets mapped lazily, on first access.

The -O2 version attempts to access the page and lands in t_page_fault,
which calls through kernel_trap to the VM subsystem, finds a free
physical page, maps it in, irets back, and everything works out fine.
The -O0 version for some reason lands in a_dbl_fault, and then
proceeds to crash.

This is probably the first time a page fault happens / is supposed to
happen during execution. So it's probably unrelated to ELF loading and
related to the VM subsystem and/or interrupt handling.

The relevant parts of the code (copyout, interrupt/exception/trap
handlers) are all written in assembly and so cannot be impacted by C
optimization level.

I don't know/understand enough about how interrupts work and x86
hardware details to make anything out of this.

Sergey

Reply via email to