mini_racer: mini_racer 0.12.0 Segmentation fault on x86_64-linux with libv8-node 21.7.2.0

Hello the team

Thank you for the update to libv8-node 21.7.2.0 yesterday. I wanted to report an error. Setup:

  • mini_racer 0.12.0
  • libv8-node 21.7.2.0
  • ruby 3.2.3
  • OS: Ubuntu 22.04.3 LTS (from CircleCI cimg/ruby:3.2.3-node)
  • Rails: 6.1.7.7
  • Sprockets: 4.2.1
  • The command: RAILS_ENV=production SECRET_KEY_BASE=1 bin/rails assets:clobber assets:precompile
/home/circleci/ec/vendor/ruby/3.2.0/gems/mini_racer-0.12.0/lib/mini_racer.rb:228: [BUG] Segmentation fault at 0x00007f3f10a31008
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0048 p:---- s:0301 e:000300 CFUNC  :eval_unsafe
c:0047 p:0009 s:0295 e:000294 BLOCK  /home/circleci/repo/vendor/ruby/3.2.0/gems/mini_racer-0.12.0/lib/mini_racer.rb:228
c:0046 p:0010 s:0292 e:000291 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/mini_racer-0.12.0/lib/mini_racer.rb:348
c:0045 p:0008 s:0281 e:000280 BLOCK  /home/circleci/repo/vendor/ruby/3.2.0/gems/mini_racer-0.12.0/lib/mini_racer.rb:227 [FINISH]
c:0044 p:---- s:0278 e:000277 CFUNC  :synchronize
c:0043 p:0045 s:0274 e:000273 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/mini_racer-0.12.0/lib/mini_racer.rb:225
c:0042 p:0007 s:0267 e:000266 BLOCK  /home/circleci/repo/vendor/ruby/3.2.0/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:11
c:0041 p:0003 s:0264 e:000262 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:67
c:0040 p:0035 s:0256 e:000255 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:10 [FINISH]
c:0039 p:---- s:0249 e:000248 CFUNC  :new
c:0038 p:0038 s:0242 e:000241 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/execjs-2.9.1/lib/execjs/runtime.rb:68
c:0037 p:0013 s:0236 e:000235 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/execjs-2.9.1/lib/execjs/module.rb:27
c:0036 p:0020 s:0230 e:000229 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/terser-1.2.2/lib/terser.rb:189
c:0035 p:0065 s:0223 e:000221 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/terser-1.2.2/lib/terser.rb:229
SEGV received in SEGV handler
c:0034 p:0014 s:0212 e:000211 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/terser-1.2.2/lib/terser.rb:181
c:0033 p:0029 s:0206 e:000205 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/terser-1.2.2/lib/terser/compressor.rb:36
c:0032 p:0007 s:0198 e:000197 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/terser-1.2.2/lib/terser/compressor.rb:23
c:0031 p:0047 s:0193 e:000192 METHOD /home/circleci/repo/vendor/ruby/3.2.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:84
c:0030 p:0013 s:0185 e:000184 BLOCK  /home/circleci/repo/vendor/ruby/3.2.0/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:66 [FINISH]
c:0029 p:---- s:0180 e:000179 CFUNC  :reverse_each
c:0028 p:0035 
Received "aborted" signal

It does work on Darwin Kernel Version 23.2.0 arm64 (Mac on arm) that compile from source.

The error is from eval -> eval_unsafe, so I suspect it is an issue with the libv8-node https://github.com/rubyjs/mini_racer/blob/5b2a25cdb4c84c7500ed47639ef8c664f5bac26d/lib/mini_racer.rb#L228

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 9
  • Comments: 105

Commits related to this issue

Most upvoted comments

This does reproduce it in docker:

docker run -it --rm ruby:3.0
gem install rails -v 6.1.7.7
rails new --skip-javascript app
cd app

echo "gem 'mini_racer', '~> 0.12.0'" >> Gemfile
echo 'gem "autoprefixer-rails", "10.4.16.0"' >> Gemfile

bundle install
./bin/rails assets:clobber assets:precompile

I looked at the files and there is nothing special about them, the backtrace for the segfault is on cleanup.

specifically miniracer calling deallocate from the finalize_list in ruby and free_context_raw leading to a segfault.

@lloeki is this enough for you to debug, or do you need more help here? One possibility here is that somehow autoprefixer is forking processes, I looked at the code and it does not look like it.

The crash looks like is is from

if (isolate_info) { isolate_info->release(); }

@SamSaffron Yeah I think I can fit that in this week’s schedule.

Ruby 2.7 is EOL

It’s not so much for the Ruby version than the glibc one.

thanks so much for the instruction … CPU is running hot now 😃

If this is any help, @SamSaffron’s repro did work for me and I traced the segfault a bit further down to this line:

https://github.com/rubyjs/mini_racer/blob/5b2a25cdb4c84c7500ed47639ef8c664f5bac26d/ext/mini_racer_extension/mini_racer_extension.cc#L1434

I forced libv8-node down to 20.12.1.0 and the issue went away, so perhaps it’s possible that it’s either a bug in 21.7.2.0 or a breaking change requiring an update?

Edit: for those who don’t know (like me before yesterday!) that isolate in the line I think is a v8::Isolate, i.e. part of V8 proper and not mini_racer.

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 ruby -r rbconfig -e "puts RbConfig::CONFIG['MAINLIBS']"

LD_PRELOAD wouldn’t change RbConfig::CONFIG['MAINLIBS'] output, it’d just forcefully inject jemalloc symbols into it.

In any case it appears that RbConfig::CONFIG['MAINLIBS'] doesn’t contain anything about jemalloc anyway, even when statically built against jemalloc.

I’m not able to reproduce the issue in a local docker either.

I couldn’t reproduce it either inside that x86_64 image: test suite passes, even when artificially stressing libv8 by throwing copious amounts of quickly hacked JS code processing to it (granted it was a real quick test).

We are now seeing different and new issues:

#0  0x00007f9eda540e2c in __pthread_kill_implementation (threadid=1227, signo=24957, signo@entry=11, no_tid=11, no_tid@entry=0) at ./nptl/pthread_kill.c:43
#1  0x00007f9eda540e9f in __pthread_kill_internal (signo=11, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  0x00007f9eda4f1fb2 in __GI_raise (sig=sig@entry=11) at ../sysdeps/posix/raise.c:26
#3  0x00007f9edaa3ffaf in ruby_default_signal (sig=sig@entry=11) at signal.c:422
#4  0x00007f9eda82c3a9 in rb_bug_for_fatal_signal (default_sighandler=0x0, sig=sig@entry=11, ctx=ctx@entry=0x7f9ea30d1ac0, fmt=fmt@entry=0x7f9edac514d5 "Segmentation fault at %p") at error.c:1069
#5  0x00007f9edaa3ef3b in sigsegv (sig=11, info=0x7f9ea30d1bf0, ctx=0x7f9ea30d1ac0) at signal.c:926
#6  <signal handler called>
#7  0x00007f9eb5346e63 in v8::internal::WriteBarrier::MarkingSlow(v8::internal::Tagged<v8::internal::HeapObject>, v8::internal::FullHeapObjectSlot, v8::internal::Tagged<v8::internal::HeapObject>) ()
   from /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_racer-0.15.0/lib/mini_racer_extension.so
#8  0x00007f9eb55874c2 in v8::internal::Compiler::DisposeTurbofanCompilationJob(v8::internal::Isolate*, v8::internal::TurbofanCompilationJob*, bool) ()
   from /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_racer-0.15.0/lib/mini_racer_extension.so
#9  0x00007f9eb5d49740 in v8::internal::OptimizingCompileDispatcher::FlushOutputQueue(bool) () from /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_racer-0.15.0/lib/mini_racer_extension.so
#10 0x00007f9eb5d49a53 in v8::internal::OptimizingCompileDispatcher::Flush(v8::internal::BlockingBehavior) ()
   from /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_racer-0.15.0/lib/mini_racer_extension.so
#11 0x00007f9eb548239e in v8::internal::Isolate::AbortConcurrentOptimization(v8::internal::BlockingBehavior) ()
   from /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_racer-0.15.0/lib/mini_racer_extension.so
#12 0x00007f9eb5400de8 in v8::internal::Heap::CollectAllAvailableGarbage(v8::internal::GarbageCollectionReason) ()
   from /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_racer-0.15.0/lib/mini_racer_extension.so
#13 0x00007f9eb52b8914 in v8::Isolate::LowMemoryNotification() () from /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_racer-0.15.0/lib/mini_racer_extension.so
#14 0x00007f9eb5282601 in rb_isolate_low_memory_notification (self=140319468385640) at mini_racer_extension.cc:970
#15 0x00007f9edaac52fc in vm_call_cfunc_with_frame_ (stack_bottom=<optimized out>, argv=<optimized out>, argc=0, calling=<optimized out>, reg_cfp=0x7f9e7d590eb0, ec=0x7f9e9c48ebd0)
    at /tmp/ruby-build.20240822030420.245.5BFPlP/ruby-3.3.3/vm_insnhelper.c:3490

It is going to take us a bit longer to get this v8 upgrade completed

Sadly https://github.com/rubyjs/mini_racer/issues/300#issuecomment-2202876857 no longer crashes… I need a new consistent repro

oh no, and yes we just saw some of these too cc @lloeki 😢

will try debugging more this week

@tisba I think you meant 0.13.0. Yes, I just tried with 0.13.0 without success. It still seg fault in the unsafe block.

#!/bin/bash -eo pipefail
RAILS_ENV=production SECRET_KEY_BASE=1 bin/rails assets:clobber assets:precompile
I, [2024-08-01T10:15:50.803867 #8314]  INFO -- : Removed /home/circleci/ec/public/assets
yarn install v1.22.19
warning package.json: No license field
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 0.04s.
/home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:228: [BUG] Segmentation fault at 0x00007f9ca8fe03e8
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0045 p:---- s:0281 e:000280 CFUNC  :eval_unsafe
c:0044 p:0009 s:0275 e:000274 BLOCK  /home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:228
c:0043 p:0010 s:0272 e:000271 METHOD /home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:348
c:0042 p:0008 s:0261 e:000260 BLOCK  /home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:227 [FINISH]
c:0041 p:---- s:0258 e:000257 CFUNC  :synchronize
c:0040 p:0045 s:0254 e:000253 METHOD /home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:225
c:0039 p:0017 s:0247 e:000246 BLOCK  /home/circleci/.rubygems/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:28
c:0038 p:0003 s:0244 e:000242 METHOD /home/circleci/.rubygems/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:67
c:0037 p:0024 s:0236 e:000235 METHOD /home/circleci/.rubygems/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:27
c:0036 p:0025 s:0230 e:000229 METHOD /home/circleci/.rubygems/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:35
c:0035 p:0071 s:0224 e:000222 METHOD /home/circleci/.rubygems/gems/terser-1.2.3/lib/terser.rb:229
c:0034 p:0014 s:0213 e:000212 METHOD /home/circleci/.rubygems/gems/terser-1.2.3/lib/terser.rb:181
c:0033 p:0029 s:0207 e:000206 METHOD /home/circleci/.rubygems/gems/terser-1.2.3/lib/terser/compressor.rb:36
c:0032 p:0007 s:0199 e:000198 METHOD /home/circleci/.rubygems/gems/terser-1.2.3/lib/terser/compressor.rb:23
c:0031 p:0047 s:0194 e:000193 METHOD /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:84
c:0030 p:0013 s:0186 e:000185 BLOCK  /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:66 [FINISH]
c:0029 p:---- s:0181 e:000180 CFUNC  :reverse_each
c:0028 p:0035 s:0177 e:000176 METHOD /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:65
c:0027 p:0395 s:0169 e:000168 METHOD /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/loader.rb:184
c:0026 p:0054 s:0145 e:000144 BLOCK  /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/loader.rb:59
c:0025 p:0033 s:0139 e:000138 METHOD /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/loader.rb:339
c:0024 p:0115 s:0129 e:000128 METHOD /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/loader.rb:43
c:0023 p:0006 s:0120 e:000119 BLOCK  /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/cached_environment.rb:44
c:0022 p:0013 s:0117 e:000114 BLOCK  /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/map.rb:207
c:0021 p:0033 s:0112 e:000111 METHOD /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/map.rb:187
c:0020 p:0010 s:0105 e:000104 METHOD /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/map.rb:206
c:0019 p:0008 s:0099 e:000098 METHOD /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/cached_environment.rb:44
c:0018 p:0025 s:0094 e:000093 METHOD /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/base.rb:81
c:0017 p:0023 s:0086 e:000085 METHOD /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/base.rb:88 [FINISH]
c:0016 p:---- s:0075 e:000074 CFUNC  :each
c:0015 p:---- s:0072 e:000071 CFUNC  :to_a
c:0014 p:0009 s:0068 e:000067 BLOCK  /home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/manifest.rb:125
c:0013 p:0010 s:0065 e:000064 BLOCK  /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24
c:0012 p:0002 s:0061 e:000060 BLOCK  /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48 [FINISH]
c:0011 p:---- s:0058 e:000057 CFUNC  :synchronize
c:0010 p:0016 s:0054 e:000053 METHOD /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48
c:0009 p:0014 s:0050 e:000049 METHOD /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22
c:0008 p:0015 s:0042 e:000041 BLOCK  /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/promise.rb:564
c:0007 p:0008 s:0036 e:000035 METHOD /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:359
c:0006 p:0041 s:0028 e:000027 BLOCK  /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:350
c:0005 p:0018 s:0022 e:000021 METHOD <internal:kernel>:187
c:0004 p:0004 s:0017 e:000016 BLOCK  /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:341 [FINISH]
c:0003 p:---- s:0014 e:000013 CFUNC  :catch
c:0002 p:0006 s:0009 e:000008 BLOCK  /home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:340 [FINISH]
c:0001 p:---- s:0003 e:000002 DUMMY  [FINISH]

-- Ruby level backtrace information ----------------------------------------
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:340:in `block in create_worker'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:340:in `catch'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:341:in `block (2 levels) in create_worker'
<internal:kernel>:187:in `loop'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:350:in `block (3 levels) in create_worker'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:359:in `run_task'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `block in synchronize'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/manifest.rb:125:in `to_a'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/manifest.rb:125:in `each'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/base.rb:88:in `find_all_linked_assets'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/base.rb:81:in `find_asset'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/cached_environment.rb:44:in `load'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/map.rb:206:in `fetch_or_store'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/map.rb:187:in `fetch'
/home/circleci/.rubygems/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/map.rb:207:in `block in fetch_or_store'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/cached_environment.rb:44:in `block in load'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/loader.rb:43:in `load'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/loader.rb:339:in `fetch_asset_from_dependency_cache'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/loader.rb:59:in `block in load'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/loader.rb:184:in `load_from_unloaded'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:65:in `call_processors'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/home/circleci/.rubygems/gems/sprockets-4.2.1/lib/sprockets/processor_utils.rb:84:in `call_processor'
/home/circleci/.rubygems/gems/terser-1.2.3/lib/terser/compressor.rb:23:in `call'
/home/circleci/.rubygems/gems/terser-1.2.3/lib/terser/compressor.rb:36:in `call'
/home/circleci/.rubygems/gems/terser-1.2.3/lib/terser.rb:181:in `compile_with_map'
/home/circleci/.rubygems/gems/terser-1.2.3/lib/terser.rb:229:in `run_terserjs'
/home/circleci/.rubygems/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:35:in `call'
/home/circleci/.rubygems/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:27:in `eval'
/home/circleci/.rubygems/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:67:in `translate'
/home/circleci/.rubygems/gems/execjs-2.9.1/lib/execjs/mini_racer_runtime.rb:28:in `block in eval'
/home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:225:in `eval'
/home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:225:in `synchronize'
/home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:227:in `block in eval'
/home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:348:in `timeout'
/home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:228:in `block (2 levels) in eval'
/home/circleci/.rubygems/gems/mini_racer-0.13.0/lib/mini_racer.rb:228:in `eval_unsafe'

-- Threading information ---------------------------------------------------
Total ractor count: 1
Ruby thread count for this ractor: 38

-- Machine register context ------------------------------------------------
 RIP: 0x00007f9ca8fe0400 RBP: 0x00007f9d933f0620 RSP: 0x00007f9d933f0550
 RAX: 0x0000000000000003 RBX: 0x0000000000000000 RCX: 0x00007f9ca8fe0400
 RDX: 0x00000d18d2380069 RDI: 0x0000238071df0859 RSI: 0x0000238071de33f1
  R8: 0x0000000000000003  R9: 0x000000000000004f R10: 0x00007f9d5c2dcc99
 R11: 0x0000238071df085b R12: 0x0000238071df0859 R13: 0x00007f9d5c2c9080
 R14: 0x0000000000000003 R15: 0x00007f9d933f04c0 EFL: 0x0000000000010246

-- C level backtrace information -------------------------------------------

Received "segmentation fault" signal

@SamSaffron apologies for the lack of updates, I started building but hit some local snags. I should have them sorted out over the weekend.

I have good news @lloeki

libv8-node-22.4.0.0-x86_64-linux.gem

No longer crashes, any chance you can push this out? This may be the best possible resolution here…

  1) Failure:
MiniRacerTest#test_timeout [test/mini_racer_test.rb:1045]:
MiniRacer::ScriptTerminatedError expected but nothing was raised.

I am sure this is resolvable…

I am on glibc here yeah lets see I am building now with gcc to see if it resolves before going too crazy.

Repro:

#!/usr/bin/env ruby

require "bundler/setup"
require "mini_racer"
Thread
  .new do
    ctx = MiniRacer::Context.new
    ctx.eval(File.read("/tmp/eval.js"))
  end
  .join

eval.js is eval.js.txt

@lloeki FYI my above sample also repros outside of docker… it crashes with a segfault in the isolate->Dispose() line. I checked and the isolate is not in use, I guess the next step here is to compile this somehow on local with symbols so we can step into v8 and see where in Dispose this is crashing. will try a bit more to figure out if I can somehow make repro script, nothing complex is happening here just creating a context and then GC is clearing it up.

I’m still not able to reproduce it in a local Docker even when I use the Docker image of the CI.

I continue to investigate on the CI directly. SSH and vi for the win!

Anyway, I track down the issue. On a brand new Rails 6.1 app:

  • precompile assets: no problem
  • add mini_racer: no problem
  • add bootstrap 4: problem (let’s look at bootstrap own dependencies)
  • removed bootstrap and added sassc-rails: no problem
  • removed sassc-rails and added autoprefixer-rails 10.4.16.0: problem
  • removed autoprefixer-rails and added execjs 2.9.1: no problem

autoprefixer-rails has only execjs as dependency. In my very case, autoprefixer-rails might have some code that seg fault in the CI only.

I don’t know what else I could search.

I am indeed using puma in clustered mode, but it was working fine on 0.8.0, and starting puma in single mode gives me the same segfault in the same place. I have the suggested fork safety line in an initializer, and removing this makes no difference in any scenario.

@lloeki this looks urgent , should we roll out a release that puts us back at an earlier version while we work this out ?

Hey @D-system. A couple of question hopefully helping to narrow the issue down

  • Can you reproduce it with a freshly created rails application? On aarch64-linux my basic checks works, as well as rails new foo && cd foo && bundle install && RAILS_ENV=production SECRET_KEY_BASE=1 bin/rails assets:clobber assets:precompile using cimg/ruby:3.2.3-node.

  • Can you reproduce the issue with Ruby 3.3.0?

  • Can you confirm if you’re using jemalloc or not? Looks like the image is at least installing libjemalloc, I haven’t checked if they build Ruby against it, or using LD_PRELOAD, or using this up to the user. There have been various issues with jemalloc and mini_racer/v8. In case jemalloc is used, can you try without?