Skip to content

Conversation

@casperisfine
Copy link

We recently experienced segfaults because buffer_data_type was 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.

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.
@byroot byroot requested a review from peterzhu2118 March 1, 2023 15:56
@byroot byroot merged commit 70a83d5 into msgpack:master 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.
}

const rb_data_type_t buffer_data_type = {
static const rb_data_type_t buffer_data_type = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, is the static needed given the -fvisibility=hidden below?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 <<

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants