Comments (7)
Looks like my workers are working too long without a garbage collection. If GC triggers inside a proc which has GVL, I'm sure some other c-code somewhere is doing the allocation that's causing the error. I'm pretty sure I can fix the issue on my side, by making sure to explicitly call GC.start before doing an eval.
I'm sure there are some cases where attached procs might alloc enough memory on their own during an eval to cause a GC.
Here's the test case:
def test_start_gc
context = MiniRacer::Context.new(timeout: 10)
context.attach("echo", proc{|msg| GC.start; msg})
GC.disable
100.times { 'foo' } # alloc a handful of objects
GC.enable
assert_equal("foo", context.eval("while(true) echo('foo');"))
end
from mini_racer.
adding the GC.start before I run run any eval has mostly prevented the crashes, but adds 100ms to all of my execution times.
In fact, now that I'm thinking about it, I haven't gotten a c-level crash in a few days... of any kind.
from mini_racer.
I moved garbage collection (GC.start) to after the eval and the crashes have come back, but in less numbers. Feel like this is a really strong indicator for all of the issues. I'm going to disable garbage collection around the eval call and see if crashes go away again.
from mini_racer.
I have confirmed that under stress testing there is ZERO instances of c-level crashes (or strange ruby crashes) when garbage collection is turned off during js eval. I'm closing and referencing this issue as a 'cause'
example code:
GC.disable
result["retval"] = ctx.eval(code_to_execute)
GC.enable
from mini_racer.
Let me know how this goes:
Pretty sure I fixed this issue.
from mini_racer.
Today is launch day. I won't be able to test for a while probably. Have you run the 'tight-loop' test? (I don't have time rn)
With or without the GC.start used to cause problems if I remember correctly
def test_segfault
5000.times do
GC.start
context = MiniRacer::Context.new(timeout: 5)
context.attach("echo", proc{|msg| msg.to_sym.to_s})
assert_raises(MiniRacer::EvalError) do
context.eval("while(true) echo('foo');")
end
end
end
from mini_racer.
OK, closing this, I think this is fixed in the pre-release
from mini_racer.
Related Issues (20)
- Node 17+18: mini_racer fails to build against ruby platform gem in CI (invalid use of βv8::Name::Nameβ) HOT 1
- `MiniRacer::RuntimeError` does not handle multiline error messages correctly HOT 1
- Gem::Ext::BuildError: ERROR: Failed to build gem native extension HOT 1
- Remote Debugging JS HOT 1
- sq_mini_racer Ruby 3.1 incompatibility (`Psych::DisallowedClass`) HOT 2
- After MacOS Ventura upgrade. gem install works, bundle install does not HOT 2
- Context has no Isolate available anymore HOT 3
- bundler install error HOT 5
- Installing mini_racer 0.6 on docker M1 fails with "make: printf: Argument list too long" HOT 4
- Update default branch to `main` HOT 3
- Unexpected token p in JSON at position HOT 2
- Gem::Ext::BuildError: ERROR: Failed to build gem native extension (Ruby 2.7.4) HOT 3
- Discuss: Release version 1.0.0 and manage consumer breaking version expectations HOT 3
- Node release catch-up plan HOT 42
- CI Improvements HOT 1
- `Isolate::low_memory_notification` fails to lock Isolate HOT 5
- Error installing mini_racer: ERROR: Failed to build gem native extension HOT 7
- Undefined Conversion
- Segmentation fault when application stops (Ruby 3.2.2, HOT 11
- mini_racer not starting: `ZSt28__throw_bad_array_new_lengthv: symbol not found (LoadError)` HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mini_racer.