Fix polymorphic deallocation#1340
Open
WeiPhil wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
Recently, I ran into an allocator mismatch crash during cleanup (specifically during Python garbage collection) when working with Mitsuba:
PrincipledBsdfis compiled withalignas(16)for SIMD operations.Bsdf*pointer (so that Python takes over and deallocates it).Since the current deallocator in nanobind does placement destructors + raw
operator delete(void*)on base pointers, standard C++ dynamic delete routing seems to be bypassed during cleanup. On cleanup, this unfortunately crashes with a mismatched free in our internal build configuration where the default compiler alignment is 8.I've worked on a fix that has been working for us internally as it reverts to standard type-safe deallocations when classes have virtual destructors.
To be honest, I'm not 100% sure this is the best fix for this niche problem, but it was the only way I could find to keep the allocators happy.
Let me know what you think or if you have a better alternative!
Best,
Philippe