forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up legacy code from Buffer::reallocate and reduce window where …
…Buffer is invalid (facebookincubator#9755) Summary: Pull Request resolved: facebookincubator#9755 When running Velox with the save input on expression setting enabled, I'm occasionally seeing SIGSEGVs writing out the Vectors when the exception was thrown while resizing the offset or length Buffer in a MapVector or an ArrayVector, e.g. because of an OOM. When this happens in Buffer::reallocate it can leave the Buffer in an invalid state before the exception is caught (when the exception message is being generated) triggering the crash. While I doubt we can 100% guarantee VectorSaver won't trigger a crash we can at least fix this case. Instead of detaching buffer before reallocating it, if we detach it after we still avoid a double free and the buffer is (almost) always valid. There are windows after the old buffer is freed before MemoryPool::reallocate returns, and while setting up newBuffer where buffer would still be invalid, but these are much less likely to run into issues (these would mainly be bugs in the code). While digging through this I also noticed that the comments on MemoryPool::reallocate have gotten out of date and Buffer::reallocate is handling some unnecessary cases (newPtr can never be equal to old), so I've cleaned those up. Reviewed By: xiaoxmeng Differential Revision: D57139357 fbshipit-source-id: b2a0391a77d6ccbdee9e96f3a85bde9ab815b2e9
- Loading branch information
1 parent
ed0ecdd
commit 2c98308
Showing
3 changed files
with
122 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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