Hide all the symbols by defaults to avoid conflict#317
Merged
byroot merged 1 commit intomsgpack:masterfrom Mar 1, 2023
Merged
Conversation
We recently experienced segfaults because `buffer_data_type` was name clashing with another gem. Generally speaking, there is very few use cases for gems to expose any of their symbols, so we should just hide them all by default and avoid this problem entirely.
peterzhu2118
approved these changes
Mar 1, 2023
casperisfine
pushed a commit
to Shopify/stack_frames
that referenced
this pull request
Mar 1, 2023
Ref: msgpack/msgpack-ruby#314 (comment) We experienced some weird segfault in `msgpack_buffer_mark` we couldn't explain. Until we noticed that the object being marked wasn't a `MessagePack::Buffer` but a `StackFrames::Buffer`. Both `msgpack` and `stackframes` were using the same symbol name to declare their respective buffer type, and the msgpack one was registered first. This is the counterpart of msgpack/msgpack-ruby#317 and generally speaking all gems should compile with `-fvisibility=hidden`.
casperisfine
pushed a commit
to casperisfine/trilogy
that referenced
this pull request
Mar 9, 2023
Otherwise, while unlikely, if another gem define similar symbols it can lead to cratastorpic issues. See msgpack/msgpack-ruby#317 for an example.
eregon
reviewed
Apr 1, 2023
| } | ||
|
|
||
| const rb_data_type_t buffer_data_type = { | ||
| static const rb_data_type_t buffer_data_type = { |
Contributor
There was a problem hiding this comment.
I wonder, is the static needed given the -fvisibility=hidden below?
Member
There was a problem hiding this comment.
Yes, but -fvisibility=hidden may not work on some platforms, or so I've heard. I still need to cleanup extconf to use append_cflags instead of $CFLAGS <<
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.
We recently experienced segfaults because
buffer_data_typewas name clashing with another gem (#314 (comment)).Generally speaking, there is very few use cases for gems to expose any of their symbols, so we should just hide them all by default and avoid this problem entirely.
@peterzhu2118
CC @flavorjones, as this may be of interest to you.