News for hackers. Stuff that matters.
Re:Debugging memory corruption: who the hell writes “2” into... by mike_hock on Sunday November 14, 2021 @04:36AM (#29216255)
> The other thing is, how can a system call block a thread but somehow that same thread runs other stuff in between that blocking call? Even if that is possible that sounds like a dangerous game to play, and this class of bugs seems natural.

I mean, signal handlers exist on Linux, too ...

> when you have a blocking syscall interrupted you will get a sigabort on linux

Doesn't the syscall just return EINTR?

Re:Debugging memory corruption: who the hell writes “2” into... by nyc_pizzadev on Sunday November 14, 2021 @07:12AM (#29216772)
The select() was not interrupted in a traditional sense. It looks like a special windows API was used (QueueUserAPC) which allows a callback to be called in user space while blocked in certain kernel calls. My guess is that when used normally, the callback returns and control goes back to select() being blocked, but in this case an exception was thrown which unrolled the stack and left the select() call holding onto an invalid stack address. Jumping out of a syscall using an exception like this will probably cause all kinds of problems and my guess this is completely unsupported.

https://docs.microsoft.com/en-us/windows/win32/api/processth...

Re:Debugging memory corruption: who the hell writes “2” into... by mike_hock on Sunday November 14, 2021 @08:10AM (#29216983)
Throwing from a signal handler on Linux is also UB. Or rather, it will blow up on Linux too, and that's why it's UB in the standard, because it'll blow up on any platform.
Re:Debugging memory corruption: who the hell writes “2” into... by ptsneves on Monday November 15, 2021 @04:23AM (#29225420)
With the understanding that somebody had complex logic in the equivalent of a signal handler in linux, then i am not sure this bug is so fantastic after all. I have signal handlers so high on my danger zone that i do not recall ever coding any. If I am in a sigabrt or sigsegv i hope i die as cleanly as possible, so that a core dump is useful. No wonder he needed kernel level development.
Re:Debugging memory corruption: who the hell writes “2” into... by mike_hock on Monday November 15, 2021 @04:45AM (#29225574)
No, absolutely not. It just illustrates the problems that obviously insane code can lead to and why we call it "insane" in the first place. But it was still a fantastic read following him on his journey from "huh, that's odd" to "I had to use kernel-level debugging to find out they were ~~throwing from an APC~~ using APC."

Imagine how much he could have achieved in those five days if he had just unfucked obvious bug magnets proactively without first painstakingly proving that they were really manifesting as bugs, and how.