Closed DrewStratford closed 5 years ago
I've done a bit of digging and I think this may be the culprit: https://github.com/SerenityOS/serenity/blob/83fdad25edfec1c8668afdff1268129e5181d78a/Kernel/Thread.cpp#L402
This doesn't seem to update, so subsequent signals from the kernel would be given the same stack pointer.
Yeah, that's probably the cause of the issue. What do you think would be a good solution?
Here's one idea: Maybe we could have something like Thread::m_signal_nesting_level
that gets incremented for every signal handler we enter, and decremented when we return from that handler. If the nesting level is non-zero, we don't overwrite esp
but keep the existing stack.
After yet more looking, I've confirmed that the signal handlers are being given the same stack. However, this isn't the only issue; when we set m_tss_to_resume_kernel
we overwrite the existing data which causes problems.
@awesomekling as for the stack pointer issue: your method would work, but I think the nicest option would be using the user space stack.
Okay, are you planning to work on this? If you can make the user space stack work, then that would be a nice option. :)
Yeah, I'll give it a go.
I had a go, but couldn't quite get something that didn't introduce subtle bugs. Someone else is free to fix this if they want.
To reproduce, run this program
and then:
which should result in something like this