-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
avoid corrupting String on conversion of StringVector to String #39726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| size_t len = jl_array_len(a); | ||
| if (len == 0) { | ||
| // this may seem like purely an optimization (which it also is), but it | ||
| // also ensures that calling `String(a)` doesn't corrupt a previous |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, but why/how exactly does a previous string get corrupted w/o this? The segfault seems to be gc-related; something about the original string now being "shared" between two strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We truncate the array here (so that future uses will get a fresh data object), but that ends up truncating the string later, if it is still the data pointer and we call this immediately. See the added tests.
fix #39717