top | item 42558203

(no title)

mhogomchungu | 1 year ago

Raymond Cheng faced a similar situation here: https://devblogs.microsoft.com/oldnewthing/20240927-00/?p=11...

The problem boils down to usage of stack memory after the memory is given to somebody else.

discuss

order

musjleman|1 year ago

> The problem boils down to usage of stack memory after the memory is given to somebody else.

While this isn't incorrect in this case the problem seems to be caused by stack unwinding without the consent of lower frames rather than a willful bug where the callee forgets about the ownership.

layer8|1 year ago

Yes, it’s the consequence of throwing exceptions through exception-unaware code, which is a problem when said code needs to perform some cleanup logic before returning, like releasing resources.

bialpio|1 year ago

WDYM? The root cause is "you passed ownership to stack-based memory to the kernel and didn't ensure it's valid when it called you back", why would "consent of lower frames" matter here? Exceptions (where lower frames matter) hid the control flow here, but that's one way to reach this situation (early return is another way, as shown by Raymond Chen's post).