deislabs / mystikos

Tools and runtime for launching unmodified container images in Trusted Execution Environments
142 stars 49 forks source link

fix memalign error in debug-malloc #1448

Closed mikbras closed 1 year ago

mikbras commented 1 year ago

This patch fixes a bug in musl libc memalign when using debug-malloc. The function myst_debug_posix_memalign() was calling into musl's memalign function, which was calling back into myst_debug_malloc(), which would have resulted in a double debug-malloc header and trailer. Consequently, free() crashed when releasing memory obtained with memalign().

mikbras commented 1 year ago

@jxyang: Thank you for your review. I committed changes to the comments to clarify that the footer is aligned. Also, I am on the fence about whether to remove the V1 function. For now, I left it as a cross check in the unlikely event that V1 and V2 don't produce the same result. :)