mini_racer 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c16fa0feb3cbf1b8421934aa90d12326e054ae439355e205f419ae1b74f6ad5
4
- data.tar.gz: ae46660f1ae64a14a528d26d53e3a1a0d7229556124cd17e0b7f5fdb16e42267
3
+ metadata.gz: d194b6215e99a045c3f3464042f03257c79317a28b093be76ef10b98a7ce84b5
4
+ data.tar.gz: 754e28ec33401634506fb3edccd8459ff84c0eb9b86c93ac967a8dca6e9f1fb0
5
5
  SHA512:
6
- metadata.gz: 55eaf9550322b6d3151b0dc17e86e9faadff9fe48cf64765d722281a8d6cd2af42ab8d46614f1ac59946aeffe2c02dbb09673042006c164e4eb132224acfe069
7
- data.tar.gz: 2b367ff94b68ed24579c6d750aef1532398bacedcd42a6149c16fbf176a76d079eddb12e9c3f15b12fb141703b0f38d37ca6e017e46d685826db64891347475e
6
+ metadata.gz: 0fe549674ed12bc928a7bd259a7ba4cd279f039dd8ea25941974f3b9748ec89ce9140f7281ff333ed21aa442b204a7ddf8b719f71f5b038a53c10792d986676b
7
+ data.tar.gz: 3b4a9c5b0fd80926a7c8dea7cec4b6a6a857d80c91e55f6fcc621fc01eda4335af46d10006e6db8bdda9c509f4900205178b8745cda4bcbd3c1333606188ec35
@@ -3,6 +3,7 @@ rvm:
3
3
  - 2.3
4
4
  - 2.4
5
5
  - 2.5
6
+ - 2.6
6
7
  - ruby-head
7
8
  matrix:
8
9
  include:
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+
2
+ - 0.2.7
3
+
4
+ - 11-11-2019
5
+
6
+ - FIX: release the file descriptor for timeout pipe earlier (this avoids holding too many files open in Ruby 2.7)
7
+
1
8
  - 14-05-2019
2
9
 
3
10
  - 0.2.6
data/README.md CHANGED
@@ -97,6 +97,27 @@ context.eval('bar()', filename: 'a/bar.js')
97
97
 
98
98
  ```
99
99
 
100
+ ### Fork safety
101
+
102
+ Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe.
103
+ Sadly Ruby does not have support for fork notifications per [#5446](https://bugs.ruby-lang.org/issues/5446).
104
+
105
+ If you want to ensure your application does not leak memory after fork either:
106
+
107
+ 1. Ensure no MiniRacer::Context objects are created in the master process
108
+
109
+ Or
110
+
111
+ 2. Dispose manually of all MiniRacer::Context objects prior to forking
112
+
113
+ ```ruby
114
+ # before fork
115
+
116
+ require 'objspace'
117
+ ObjectSpace.each_object(MiniRacer::Context){|c| c.dispose}
118
+
119
+ # fork here
120
+ ```
100
121
 
101
122
  ### Threadsafe
102
123
 
data/Rakefile CHANGED
@@ -16,6 +16,22 @@ Rake::ExtensionTask.new( 'mini_racer_extension', gem )
16
16
 
17
17
  # via http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
18
18
  namespace :test do
19
+ desc "run test suite with Address Sanitizer"
20
+ task :asan do
21
+ ENV["CONFIGURE_ARGS"] = [ENV["CONFIGURE_ARGS"], '--enable-asan'].compact.join(' ')
22
+ Rake::Task['compile'].invoke
23
+
24
+ asan_path = `ldconfig -N -p |grep libasan | grep -v 32 | sed 's/.* => \\(.*\\)$/\\1/'`.chomp.split("\n")[-1]
25
+
26
+
27
+ cmdline = "env LD_PRELOAD=\"#{asan_path}\" ruby test/test_leak.rb"
28
+ puts cmdline
29
+ system cmdline
30
+
31
+ cmdline = "env LD_PRELOAD=\"#{asan_path}\" rake test"
32
+ puts cmdline
33
+ system cmdline
34
+ end
19
35
  # partial-loads-ok and undef-value-errors necessary to ignore
20
36
  # spurious (and eminently ignorable) warnings from the ruby
21
37
  # interpreter
@@ -49,10 +49,15 @@ if CONFIG['warnflags']
49
49
  CONFIG['warnflags'].gsub!('-Wimplicit-function-declaration', '')
50
50
  end
51
51
 
52
- if enable_config('debug')
52
+ if enable_config('debug') || enable_config('asan')
53
53
  CONFIG['debugflags'] << ' -ggdb3 -O0'
54
54
  end
55
55
 
56
56
  Libv8.configure_makefile
57
57
 
58
+ if enable_config('asan')
59
+ $CPPFLAGS.insert(0, " -fsanitize=address ")
60
+ $LDFLAGS.insert(0, " -fsanitize=address ")
61
+ end
62
+
58
63
  create_makefile 'mini_racer_extension'
@@ -152,7 +152,7 @@ static VALUE rb_mJSON;
152
152
  static VALUE rb_cFailedV8Conversion;
153
153
  static VALUE rb_cDateTime = Qnil;
154
154
 
155
- static Platform* current_platform = NULL;
155
+ static std::unique_ptr<Platform> current_platform = NULL;
156
156
  static std::mutex platform_lock;
157
157
 
158
158
  static VALUE rb_platform_set_flag_as_str(VALUE _klass, VALUE flag_as_str) {
@@ -189,8 +189,8 @@ static void init_v8() {
189
189
 
190
190
  if (current_platform == NULL) {
191
191
  V8::InitializeICU();
192
- current_platform = platform::CreateDefaultPlatform();
193
- V8::InitializePlatform(current_platform);
192
+ current_platform = platform::NewDefaultPlatform();
193
+ V8::InitializePlatform(current_platform.get());
194
194
  V8::Initialize();
195
195
  }
196
196
 
@@ -241,7 +241,7 @@ static void prepare_result(MaybeLocal<Value> v8res,
241
241
  Local<Object> object = local_value->ToObject(context).ToLocalChecked();
242
242
  const unsigned argc = 1;
243
243
  Local<Value> argv[argc] = { object };
244
- MaybeLocal<Value> json = stringify->Call(JSON, argc, argv);
244
+ MaybeLocal<Value> json = stringify->Call(context, JSON, argc, argv);
245
245
 
246
246
  if (json.IsEmpty()) {
247
247
  evalRes.executed = false;
@@ -1086,8 +1086,10 @@ static VALUE rb_external_function_notify_v8(VALUE self) {
1086
1086
  Local<Context> context = context_info->context->Get(isolate);
1087
1087
  Context::Scope context_scope(context);
1088
1088
 
1089
- Local<String> v8_str = String::NewFromUtf8(isolate, RSTRING_PTR(name),
1090
- NewStringType::kNormal, (int)RSTRING_LEN(name)).ToLocalChecked();
1089
+ Local<String> v8_str =
1090
+ String::NewFromUtf8(isolate, RSTRING_PTR(name),
1091
+ NewStringType::kNormal, (int)RSTRING_LEN(name))
1092
+ .ToLocalChecked();
1091
1093
 
1092
1094
  // copy self so we can access from v8 external
1093
1095
  VALUE* self_copy;
@@ -1097,24 +1099,35 @@ static VALUE rb_external_function_notify_v8(VALUE self) {
1097
1099
  Local<Value> external = External::New(isolate, self_copy);
1098
1100
 
1099
1101
  if (parent_object == Qnil) {
1100
- context->Global()->Set(v8_str, FunctionTemplate::New(isolate, ruby_callback, external)->GetFunction());
1101
- } else {
1102
+ context->Global()->Set(
1103
+ v8_str, FunctionTemplate::New(isolate, ruby_callback, external)
1104
+ ->GetFunction(context)
1105
+ .ToLocalChecked());
1102
1106
 
1103
- Local<String> eval = String::NewFromUtf8(isolate, RSTRING_PTR(parent_object_eval),
1104
- NewStringType::kNormal, (int)RSTRING_LEN(parent_object_eval)).ToLocalChecked();
1107
+ } else {
1108
+ Local<String> eval =
1109
+ String::NewFromUtf8(isolate, RSTRING_PTR(parent_object_eval),
1110
+ NewStringType::kNormal,
1111
+ (int)RSTRING_LEN(parent_object_eval))
1112
+ .ToLocalChecked();
1105
1113
 
1106
1114
  MaybeLocal<Script> parsed_script = Script::Compile(context, eval);
1107
1115
  if (parsed_script.IsEmpty()) {
1108
- parse_error = true;
1116
+ parse_error = true;
1109
1117
  } else {
1110
- MaybeLocal<Value> maybe_value = parsed_script.ToLocalChecked()->Run(context);
1118
+ MaybeLocal<Value> maybe_value =
1119
+ parsed_script.ToLocalChecked()->Run(context);
1111
1120
  attach_error = true;
1112
1121
 
1113
1122
  if (!maybe_value.IsEmpty()) {
1114
1123
  Local<Value> value = maybe_value.ToLocalChecked();
1115
- if (value->IsObject()){
1116
- value.As<Object>()->Set(v8_str, FunctionTemplate::New(isolate, ruby_callback, external)->GetFunction());
1117
- attach_error = false;
1124
+ if (value->IsObject()) {
1125
+ value.As<Object>()->Set(
1126
+ v8_str, FunctionTemplate::New(
1127
+ isolate, ruby_callback, external)
1128
+ ->GetFunction(context)
1129
+ .ToLocalChecked());
1130
+ attach_error = false;
1118
1131
  }
1119
1132
  }
1120
1133
  }
@@ -315,7 +315,9 @@ module MiniRacer
315
315
  t.join
316
316
 
317
317
  rval
318
-
318
+ ensure
319
+ wp.close if wp
320
+ rp.close if rp
319
321
  end
320
322
 
321
323
  def check_init_options!(options)
@@ -1,3 +1,3 @@
1
1
  module MiniRacer
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_racer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-14 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler