raspi-kernel
raspi-kernel copied to clipboard
Reaping of last kernel thread leads to invalid memory access
Running processes indefinitely works as a charm. But as soon as a process finishes, the context switch does not work any longer.
I found out, that all values inside the reap
method are correct during execution. Also, when reaping the last process other than the init process, the run_queue
size is 0 after popping it, but in the very next call to schedule
, the run_queue
's size is back to 1 again. As there is in reality nothing in there, the following pop
fetches illegal content, where it starts doing weird stuff.
Verifying the pid
field of new_thread
and the current_process
also shows, that even the current_process
is an illegal access (as pid
is a high number and proc_name
is scrambled).
So I would take a wild guess, that something in the switch_to_thread
assembly may be problematic.
I would guess the reaped thread must be called to a context switch, that disregards everything from the old thread, as the memory has already been freed.
Could you please verify it or maybe you have an idea to solve that?