Skip to content
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

Ruby: segfault on Apple Silicon (M1/M2) Macs #13355

Closed
krystof-k opened this issue Jul 19, 2023 · 7 comments
Closed

Ruby: segfault on Apple Silicon (M1/M2) Macs #13355

krystof-k opened this issue Jul 19, 2023 · 7 comments

Comments

@krystof-k
Copy link

krystof-k commented Jul 19, 2023

What version of protobuf and what language are you using?
Version: 3.24.0.rc.2
Language: Ruby

What operating system (Linux, Windows, ...) and version?
macOS Ventura 13.4 (22F66)

What did you do?

I'm using pg_query gem which has protobuf as depedency.


Log
/app/vendor/bundle/ruby/2.7.0/gems/google-protobuf-3.24.0.rc.2-aarch64-linux/lib/google/protobuf/descriptor_pb.rb:13: [BUG] Segmentation fault at 0x00000000000038a0
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [aarch64-linux-musl]

-- Control frame information -----------------------------------------------
c:0053 p:---- s:0317 e:000316 CFUNC  :add_serialized_file
c:0052 p:0037 s:0312 e:000311 TOP    /app/vendor/bundle/ruby/2.7.0/gems/google-protobuf-3.24.0.rc.2-aarch64-linux/lib/google/protobuf/descriptor_pb.rb:13 [FINISH]
c:0051 p:---- s:0302 e:000301 CFUNC  :require
c:0050 p:0258 s:0297 e:000296 METHOD /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32
c:0049 p:0007 s:0287 e:000286 BLOCK  /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0048 p:0068 s:0284 e:000283 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299
c:0047 p:0010 s:0277 e:000276 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0046 p:0013 s:0271 e:000270 TOP    /app/vendor/bundle/ruby/2.7.0/gems/google-protobuf-3.24.0.rc.2-aarch64-linux/lib/google/protobuf/descriptor_dsl.rb:9 [FINISH]
c:0045 p:---- s:0267 e:000266 CFUNC  :require
c:0044 p:0258 s:0262 e:000261 METHOD /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32
c:0043 p:0007 s:0252 e:000251 BLOCK  /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0042 p:0068 s:0249 e:000248 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299
c:0041 p:0010 s:0242 e:000241 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0040 p:0089 s:0236 e:000235 TOP    /app/vendor/bundle/ruby/2.7.0/gems/google-protobuf-3.24.0.rc.2-aarch64-linux/lib/google/protobuf.rb:57 [FINISH]
c:0039 p:---- s:0233 e:000232 CFUNC  :require
c:0038 p:0258 s:0228 e:000227 METHOD /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32
c:0037 p:0007 s:0218 e:000217 BLOCK  /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0036 p:0068 s:0215 e:000214 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299
c:0035 p:0010 s:0208 e:000207 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0034 p:0005 s:0202 e:000201 TOP    /app/vendor/bundle/ruby/2.7.0/gems/pg_query-2.2.1/lib/pg_query/pg_query_pb.rb:4 [FINISH]
c:0033 p:---- s:0199 e:000198 CFUNC  :require
c:0032 p:0258 s:0194 e:000193 METHOD /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32
c:0031 p:0007 s:0184 e:000183 BLOCK  /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0030 p:0068 s:0181 e:000180 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299
c:0029 p:0010 s:0174 e:000173 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0028 p:0017 s:0168 e:000167 TOP    /app/vendor/bundle/ruby/2.7.0/gems/pg_query-2.2.1/lib/pg_query.rb:4 [FINISH]
c:0027 p:---- s:0165 e:000164 CFUNC  :require
c:0026 p:0258 s:0160 e:000159 METHOD /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32
c:0025 p:0032 s:0150 e:000149 BLOCK  /usr/local/bundle/gems/bundler-2.4.8/lib/bundler/runtime.rb:60 [FINISH]
c:0024 p:---- s:0145 e:000144 CFUNC  :each
c:0023 p:0042 s:0141 e:000140 BLOCK  /usr/local/bundle/gems/bundler-2.4.8/lib/bundler/runtime.rb:55 [FINISH]
c:0022 p:---- s:0134 e:000133 CFUNC  :each
c:0021 p:0026 s:0130 e:000129 METHOD /usr/local/bundle/gems/bundler-2.4.8/lib/bundler/runtime.rb:44
c:0020 p:0013 s:0125 e:000124 METHOD /usr/local/bundle/gems/bundler-2.4.8/lib/bundler.rb:195
c:0019 p:0042 s:0120 e:000119 TOP    /app/config/application.rb:8 [FINISH]
c:0018 p:---- s:0117 e:000116 CFUNC  :require
c:0017 p:0258 s:0112 e:000111 METHOD /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32
c:0016 p:0007 s:0102 e:000101 BLOCK  /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0015 p:0068 s:0099 e:000098 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299
c:0014 p:0010 s:0092 e:000091 METHOD /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332
c:0013 p:0013 s:0086 e:000085 BLOCK  /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/commands/server/server_command.rb:138 [FINISH]
c:0012 p:---- s:0081 e:000080 CFUNC  :tap
c:0011 p:0033 s:0077 e:000076 METHOD /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/commands/server/server_command.rb:135
c:0010 p:0054 s:0073 e:000072 METHOD /app/vendor/bundle/ruby/2.7.0/gems/thor-1.2.2/lib/thor/command.rb:27
c:0009 p:0040 s:0065 e:000064 METHOD /app/vendor/bundle/ruby/2.7.0/gems/thor-1.2.2/lib/thor/invocation.rb:127
c:0008 p:0235 s:0058 e:000057 METHOD /app/vendor/bundle/ruby/2.7.0/gems/thor-1.2.2/lib/thor.rb:392
c:0007 p:0045 s:0045 e:000044 METHOD /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/command/base.rb:69
c:0006 p:0149 s:0038 e:000037 METHOD /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/command.rb:48
c:0005 p:0063 s:0026 e:000025 TOP    /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/commands.rb:18 [FINISH]
c:0004 p:---- s:0021 e:000020 CFUNC  :require
c:0003 p:0258 s:0016 e:000015 METHOD /app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32
c:0002 p:0031 s:0006 e:000005 EVAL   bin/rails:4 [FINISH]
c:0001 p:0000 s:0003 E:000470 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
bin/rails:4:in `<main>'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/commands.rb:18:in `<main>'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/command.rb:48:in `invoke'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/command/base.rb:69:in `perform'
/app/vendor/bundle/ruby/2.7.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
/app/vendor/bundle/ruby/2.7.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
/app/vendor/bundle/ruby/2.7.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/commands/server/server_command.rb:135:in `perform'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/commands/server/server_command.rb:135:in `tap'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.4/lib/rails/commands/server/server_command.rb:138:in `block in perform'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299:in `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/config/application.rb:8:in `<main>'
/usr/local/bundle/gems/bundler-2.4.8/lib/bundler.rb:195:in `require'
/usr/local/bundle/gems/bundler-2.4.8/lib/bundler/runtime.rb:44:in `require'
/usr/local/bundle/gems/bundler-2.4.8/lib/bundler/runtime.rb:44:in `each'
/usr/local/bundle/gems/bundler-2.4.8/lib/bundler/runtime.rb:55:in `block in require'
/usr/local/bundle/gems/bundler-2.4.8/lib/bundler/runtime.rb:55:in `each'
/usr/local/bundle/gems/bundler-2.4.8/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/pg_query-2.2.1/lib/pg_query.rb:4:in `<main>'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299:in `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/pg_query-2.2.1/lib/pg_query/pg_query_pb.rb:4:in `<main>'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299:in `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/google-protobuf-3.24.0.rc.2-aarch64-linux/lib/google/protobuf.rb:57:in `<main>'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299:in `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/google-protobuf-3.24.0.rc.2-aarch64-linux/lib/google/protobuf/descriptor_dsl.rb:9:in `<main>'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:299:in `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.4/lib/active_support/dependencies.rb:332:in `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/google-protobuf-3.24.0.rc.2-aarch64-linux/lib/google/protobuf/descriptor_pb.rb:13:in `<main>'
/app/vendor/bundle/ruby/2.7.0/gems/google-protobuf-3.24.0.rc.2-aarch64-linux/lib/google/protobuf/descriptor_pb.rb:13:in `add_serialized_file'

Might be (somehow) related to #11968.

@krystof-k krystof-k added the untriaged auto added to all issues by default when created. label Jul 19, 2023
@haberman
Copy link
Member

To debug an issue like this, we need a repro.

Does simply importing pg_query in an empty app trigger the crash?

If not, how much of your app can you delete and still get the crash? I recommend trying this on a branch. Try deleting things until you have the smallest amount of code that still triggers the crash.

@krystof-k
Copy link
Author

Yeah, I guess. Actually, there is no code using the gem in the app, just the gem in the Gemfile.

@sbenzaquen sbenzaquen added wait for user action and removed untriaged auto added to all issues by default when created. labels Jul 19, 2023
@haberman
Copy link
Member

haberman commented Jul 19, 2023

On my M1 mac, I tried the following:

$ /opt/homebrew/opt/ruby/bin/gem install pg_query
$ /opt/homebrew/opt/ruby/bin/ruby -e "require 'pg_query'"
$ /opt/homebrew/opt/ruby/bin/gem list google-protobuf

*** LOCAL GEMS ***

google-protobuf (3.24.0.rc.2 arm64-darwin)

This did not reproduce the crash. So it appears that merely importing pg_query is not enough to reproduce this issue.

So we still need a repro before we can debug this.

@krystof-k
Copy link
Author

I'm running it in Docker (Alpine 3.16) which probably results in using different architecture (aarch64-linux), can it be different?

@haberman
Copy link
Member

I'm running it in Docker (Alpine 3.16) which probably results in using different architecture (aarch64-linux), can it be different?

It could be that, or it could be a hundred other things about your setup. The only way to find out is to reduce the crash until you have a minimal repro.

There are some tips for creating a minimal repro here: https://stackoverflow.com/help/minimal-reproducible-example

@haberman
Copy link
Member

Actually, now that you mention it, I don't think our binary gems are compatible with Alpine, see: #12904 (comment)

That comment also contains workarounds for this.

@krystof-k
Copy link
Author

I see. Thanks, I missed that issue.

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

No branches or pull requests

3 participants