microcom icon indicating copy to clipboard operation
microcom copied to clipboard

Fix some UB in signal handling

Open a3f opened this issue 6 years ago • 2 comments

While looking over #15, I noticed some issues with the way microcom handles signals. This fixes what was straight forward to fix. What remains is the access to ios, ios->exit and whatever is called there. With #15 merged, this could be fixed by peppering some volatile around, but it's very unlikely to happen so postponing this for now.

a3f avatar Aug 25 '19 19:08 a3f

Sorry, github UI problems. I only intended to approve the first commit.

ukleinek avatar Aug 25 '19 21:08 ukleinek

Hmm, I don't particularly like this. I'd like to allow backends calling async-unsafe functions.

We could longjmp back into main and exit regularly there. Thinking about it, I like this approach more as well. What do you think? (EDIT: Thinking some more about this, this is non-nonsensical. If you call an async-signal-unsafe function after a longjmp, you run into UB as well.)

Freeing ios in global code seems to work, but is a layer violation because the structure was allocated in the backends.

Is it? malloc, calloc and strdup are all free'd by the same free. Same goes for open, socket and creat, which are all destructed by close.

a3f avatar Aug 25 '19 21:08 a3f