Railsで「[BUG] Segmentation fault at 0x00...」が表示された時の対処法

created
updated

Railsでサーバーを起動した時[BUG] Segmentation fault at 0x00...が表示されたので、その対処方法をまとめました。

/usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/bootsnap.so: [BUG] Segmentation fault at 0x00...

起動時のエラー内容

$ docker-compose exec {コンテナ名} bundle exec rails s -b 0.0.0.0

/usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/bootsnap.so: [BUG] Segmentation fault at 0x00000000000011c6
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-musl]
-- Control frame information -----------------------------------------------
c:0035 p:-17467383436366 s:0194 e:000193 TOP    [FINISH]
c:0034 p:---- s:0191 e:000190 CFUNC  :require
c:0033 p:0012 s:0186 e:000185 BLOCK  /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23
c:0032 p:0070 s:0183 e:000182 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92
c:0031 p:0025 s:0171 e:000170 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22
c:0030 p:0065 s:0165 e:000164 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31
c:0029 p:0005 s:0157 e:000156 TOP    /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/compile_cache/iseq.rb:2 [FINISH]
c:0028 p:---- s:0154 e:000153 CFUNC  :require
c:0027 p:0012 s:0149 e:000148 BLOCK  /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23
c:0026 p:0070 s:0146 e:000145 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92
c:0025 p:0025 s:0134 e:000133 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22
c:0024 p:0065 s:0128 e:000127 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31
c:0023 p:0035 s:0120 e:000119 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53
c:0022 p:0014 s:0114 e:000113 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/compile_cache.rb:10
c:0021 p:0094 s:0106 e:000105 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap.rb:69
c:0020 p:0279 s:0094 e:000093 METHOD /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap.rb:110
c:0019 p:0017 s:0084 e:000083 TOP    /usr/local/bundle/gems/bootsnap-1.7.5/lib/bootsnap/setup.rb:4 [FINISH]
c:0018 p:---- s:0081 e:000080 CFUNC  :require
c:0017 p:0053 s:0076 e:000075 TOP    /app/config/boot.rb:4 [FINISH]
c:0016 p:---- s:0073 e:000072 CFUNC  :require_relative
c:0015 p:0045 s:0068 e:000067 TOP    /app/bin/rails:4 [FINISH]
c:0014 p:---- s:0065 e:000064 CFUNC  :load
c:0013 p:0130 s:0060 e:000059 METHOD /usr/local/bundle/gems/spring-2.1.1/lib/spring/client/rails.rb:28
c:0012 p:0007 s:0055 e:000054 METHOD /usr/local/bundle/gems/spring-2.1.1/lib/spring/client/command.rb:7
c:0011 p:0011 s:0050 e:000049 METHOD /usr/local/bundle/gems/spring-2.1.1/lib/spring/client.rb:30
c:0010 p:0302 s:0044 e:000043 TOP    /usr/local/bundle/gems/spring-2.1.1/bin/spring:49 [FINISH]
c:0009 p:---- s:0038 e:000037 CFUNC  :load
c:0008 p:0114 s:0033 e:000032 TOP    /usr/local/bundle/gems/spring-2.1.1/lib/spring/binstub.rb:11 [FINISH]
c:0007 p:---- s:0027 e:000026 CFUNC  :require
c:0006 p:0065 s:0022 e:000021 BLOCK  /app/bin/spring:10
c:0005 p:0003 s:0018 e:000017 METHOD <internal:kernel>:90
c:0004 p:0073 s:0014 e:000013 TOP    /app/bin/spring:7 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC  :load
c:0002 p:0019 s:0006 e:000005 EVAL   bin/rails:2 [FINISH]

対応方法

$ docker-compose exec {コンテナ名} bash

# コンテナ内にて実行
$ rm -rf ./bundle ./node_modules ./tmp
$ exit

$ docker-compose restart
$ docker-compose exec {コンテナ名} bundle install
$ docker-compose exec {コンテナ名} yarn install # または docker-compose exec {コンテナ名} npm install

一度ライブラリや一時ファイルをクリアすると、起動できました。

TOP