-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(array): use-after-free in optimized String array (#5377)
* chore: modify tests to exercise use after free bugs Test that potential use after free bugs can be exercised through the flux language by modifying executetest.ProcessTestHelper2 to use a memory allocator that scrubs the memory buffer when freeing. * fix(array): prevent use-after-free errors with string arrays The optimised string arrays did not always copy values before freeing the backing data, leading to potentially unpredictable behaviour. Because the default allocator, which is presumably used in most circumstances, uses the go runtime allocator underneath it is likely that this wouldn't normally affect the correctness of operations. The more likely problem is that large memory blocks that the execution engine thinks has been freed are not being garbage collected because of refences to strings within the memory block. The array.StringBuilder is changed to always copy the value into an internal memory buffer when a value is appended, The internal buffer will always be allocated from the the memory allocator. When retriving a string value from array.String the returned value will be a copy from the internal buffer. This makes the string much easier to reason about as it fits with the standard go string semantics. This string is allocated by the go runtime rather than the memory allocator. The above changes make the system safer, but are likely to introduce a reduction in performance due to the increase in copying of data in memory. In order to provide a faster path some byte slice based methods have been added to allow for less copying in places where it can easily be determined that values will be finished with before the memory is freed. * feat(array): reduced copy string concatenate Create custom string addition (concatenation) functions that limit the amount of copying required for the operation. * chore(stdlib): reduced memory copying for string columns In places where it is clearly safe to do so use the byte-slice oriented string column functions to minimize the amount of data copies that are made when processing string columns.
- Loading branch information
Showing
14 changed files
with
241 additions
and
109 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
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
Oops, something went wrong.