mini_racer 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -1
- data/ext/mini_racer_extension/extconf.rb +5 -0
- data/ext/mini_racer_extension/mini_racer_extension.cc +51 -44
- data/lib/mini_racer/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e832863760637f983976194ebef263d8815c149d48ff26c7200367ab33640dda
|
4
|
+
data.tar.gz: 7c1c393ae6403a75d2a413395d56e7d5f3affe706b81c121273b4c6b5d471bf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4504cb3a564e5b311b65de74bac321b058995af17df47f9f3dc01fcb589a87eebfda55497e0ddb135a2ab15ef1818760652561d434d3f497c0dbd036451934c6
|
7
|
+
data.tar.gz: b83df123a61092ab4041212bb6e4f15b276d5e32e8be8d2b5cbc014988b8cf20ed0e0b3b30595de53ca4c0d599a86112d695009cda13891fe177742aff7d911e
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
- 17-01-2021
|
2
|
+
|
3
|
+
- 0.6.2
|
4
|
+
|
5
|
+
- Fix support for compilation on 2.6, llvm compiles
|
6
|
+
- Stability patches to handle rare memory leaks
|
7
|
+
- Corrected re-raising of exceptions to support strings
|
8
|
+
- During early termination of context under certain conditions MiniRacer could crash
|
9
|
+
|
10
|
+
|
1
11
|
- 31-12-2021
|
2
12
|
|
3
13
|
- 0.6.1
|
@@ -18,7 +28,6 @@
|
|
18
28
|
- Fixes issues on aarch (Apple M1)
|
19
29
|
- Update to use libv8-node 16.x (#210) [Loic Nageleisen]
|
20
30
|
- FEATURE: Configurable max marshal stack depth (#202) [seanmakesgames]
|
21
|
-
- FEATURE: Configurable max marshal stack depth (#202) [seanmakesgames]
|
22
31
|
- Ruby 2.3 and 2.4 are EOL, we no longer support them
|
23
32
|
|
24
33
|
- 0.4.0
|
@@ -75,4 +75,9 @@ if enable_config('asan')
|
|
75
75
|
$LDFLAGS.insert(0, " -fsanitize=address ")
|
76
76
|
end
|
77
77
|
|
78
|
+
# there doesn't seem to be a CPP macro for this in Ruby 2.6:
|
79
|
+
if RUBY_ENGINE == 'ruby'
|
80
|
+
$CPPFLAGS += ' -DENGINE_IS_CRUBY '
|
81
|
+
end
|
82
|
+
|
78
83
|
create_makefile 'mini_racer_extension'
|
@@ -2,6 +2,7 @@
|
|
2
2
|
#include <ruby.h>
|
3
3
|
#include <ruby/thread.h>
|
4
4
|
#include <ruby/io.h>
|
5
|
+
#include <ruby/version.h>
|
5
6
|
#include <v8.h>
|
6
7
|
#include <v8-profiler.h>
|
7
8
|
#include <libplatform/libplatform.h>
|
@@ -13,6 +14,14 @@
|
|
13
14
|
#include <math.h>
|
14
15
|
#include <errno.h>
|
15
16
|
|
17
|
+
/* workaround C Ruby <= 2.x problems w/ clang in C++ mode */
|
18
|
+
#if defined(ENGINE_IS_CRUBY) && \
|
19
|
+
RUBY_API_VERSION_MAJOR == 2 && RUBY_API_VERSION_MINOR <= 6
|
20
|
+
# define MR_METHOD_FUNC(fn) RUBY_METHOD_FUNC(fn)
|
21
|
+
#else
|
22
|
+
# define MR_METHOD_FUNC(fn) fn
|
23
|
+
#endif
|
24
|
+
|
16
25
|
using namespace v8;
|
17
26
|
|
18
27
|
typedef struct {
|
@@ -337,7 +346,7 @@ static VALUE rb_platform_set_flag_as_str(VALUE _klass, VALUE flag_as_str) {
|
|
337
346
|
if (!strcmp(RSTRING_PTR(flag_as_str), "--single_threaded")) {
|
338
347
|
single_threaded = true;
|
339
348
|
}
|
340
|
-
V8::SetFlagsFromString(RSTRING_PTR(flag_as_str), (
|
349
|
+
V8::SetFlagsFromString(RSTRING_PTR(flag_as_str), RSTRING_LENINT(flag_as_str));
|
341
350
|
} else {
|
342
351
|
platform_already_initialized = true;
|
343
352
|
}
|
@@ -409,28 +418,32 @@ static void prepare_result(MaybeLocal<Value> v8res,
|
|
409
418
|
Local<Value> local_value = v8res.ToLocalChecked();
|
410
419
|
if ((local_value->IsObject() || local_value->IsArray()) &&
|
411
420
|
!local_value->IsDate() && !local_value->IsFunction()) {
|
412
|
-
|
413
|
-
context, String::NewFromUtf8Literal(isolate, "JSON"))
|
414
|
-
.ToLocalChecked().As<Object>();
|
415
|
-
|
416
|
-
Local<Function> stringify = JSON->Get(
|
417
|
-
context, v8::String::NewFromUtf8Literal(isolate, "stringify"))
|
418
|
-
.ToLocalChecked().As<Function>();
|
419
|
-
|
420
|
-
Local<Object> object = local_value->ToObject(context).ToLocalChecked();
|
421
|
-
const unsigned argc = 1;
|
422
|
-
Local<Value> argv[argc] = { object };
|
423
|
-
MaybeLocal<Value> json = stringify->Call(context, JSON, argc, argv);
|
421
|
+
MaybeLocal<v8::Value> ml = context->Global()->Get(
|
422
|
+
context, String::NewFromUtf8Literal(isolate, "JSON"));
|
424
423
|
|
425
|
-
if (
|
424
|
+
if (ml.IsEmpty()) { // exception
|
426
425
|
evalRes.executed = false;
|
427
426
|
} else {
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
427
|
+
Local<Object> JSON = ml.ToLocalChecked().As<Object>();
|
428
|
+
|
429
|
+
Local<Function> stringify = JSON->Get(
|
430
|
+
context, v8::String::NewFromUtf8Literal(isolate, "stringify"))
|
431
|
+
.ToLocalChecked().As<Function>();
|
432
|
+
|
433
|
+
Local<Object> object = local_value->ToObject(context).ToLocalChecked();
|
434
|
+
const unsigned argc = 1;
|
435
|
+
Local<Value> argv[argc] = { object };
|
436
|
+
MaybeLocal<Value> json = stringify->Call(context, JSON, argc, argv);
|
437
|
+
|
438
|
+
if (json.IsEmpty()) {
|
439
|
+
evalRes.executed = false;
|
440
|
+
} else {
|
441
|
+
evalRes.json = true;
|
442
|
+
Persistent<Value>* persistent = new Persistent<Value>();
|
443
|
+
persistent->Reset(isolate, json.ToLocalChecked());
|
444
|
+
evalRes.value = persistent;
|
445
|
+
}
|
432
446
|
}
|
433
|
-
|
434
447
|
} else {
|
435
448
|
Persistent<Value>* persistent = new Persistent<Value>();
|
436
449
|
persistent->Reset(isolate, local_value);
|
@@ -711,7 +724,7 @@ static Local<Value> convert_ruby_to_v8(Isolate* isolate, Local<Context> context,
|
|
711
724
|
case T_FLOAT:
|
712
725
|
return scope.Escape(Number::New(isolate, NUM2DBL(value)));
|
713
726
|
case T_STRING:
|
714
|
-
return scope.Escape(String::NewFromUtf8(isolate, RSTRING_PTR(value), NewStringType::kNormal, (
|
727
|
+
return scope.Escape(String::NewFromUtf8(isolate, RSTRING_PTR(value), NewStringType::kNormal, RSTRING_LENINT(value)).ToLocalChecked());
|
715
728
|
case T_NIL:
|
716
729
|
return scope.Escape(Null(isolate));
|
717
730
|
case T_TRUE:
|
@@ -739,7 +752,7 @@ static Local<Value> convert_ruby_to_v8(Isolate* isolate, Local<Context> context,
|
|
739
752
|
return scope.Escape(object);
|
740
753
|
case T_SYMBOL:
|
741
754
|
value = rb_funcall(value, rb_intern("to_s"), 0);
|
742
|
-
return scope.Escape(String::NewFromUtf8(isolate, RSTRING_PTR(value), NewStringType::kNormal, (
|
755
|
+
return scope.Escape(String::NewFromUtf8(isolate, RSTRING_PTR(value), NewStringType::kNormal, RSTRING_LENINT(value)).ToLocalChecked());
|
743
756
|
case T_DATA:
|
744
757
|
klass = rb_funcall(value, rb_intern("class"), 0);
|
745
758
|
if (klass == rb_cTime || klass == rb_cDateTime)
|
@@ -1057,7 +1070,7 @@ static VALUE convert_result_to_ruby(VALUE self /* context */,
|
|
1057
1070
|
// a v8 scope, if we do the scope is never cleaned up properly and we leak
|
1058
1071
|
if (!result.parsed) {
|
1059
1072
|
if(TYPE(message) == T_STRING) {
|
1060
|
-
rb_raise(rb_eParseError, "%
|
1073
|
+
rb_raise(rb_eParseError, "%" PRIsVALUE, message);
|
1061
1074
|
} else {
|
1062
1075
|
rb_raise(rb_eParseError, "Unknown JavaScript Error during parse");
|
1063
1076
|
}
|
@@ -1081,15 +1094,17 @@ static VALUE convert_result_to_ruby(VALUE self /* context */,
|
|
1081
1094
|
|
1082
1095
|
// exception report about what happened
|
1083
1096
|
if (TYPE(backtrace) == T_STRING) {
|
1084
|
-
rb_raise(ruby_exception, "%
|
1097
|
+
rb_raise(ruby_exception, "%" PRIsVALUE, backtrace);
|
1085
1098
|
} else if(TYPE(message) == T_STRING) {
|
1086
|
-
rb_raise(ruby_exception, "%
|
1099
|
+
rb_raise(ruby_exception, "%" PRIsVALUE, message);
|
1087
1100
|
} else {
|
1088
1101
|
rb_raise(ruby_exception, "Unknown JavaScript Error during execution");
|
1089
1102
|
}
|
1103
|
+
} else if (rb_obj_is_kind_of(ruby_exception, rb_eException)) {
|
1104
|
+
rb_exc_raise(ruby_exception);
|
1090
1105
|
} else {
|
1091
1106
|
VALUE rb_str = rb_funcall(ruby_exception, rb_intern("to_s"), 0);
|
1092
|
-
rb_raise(CLASS_OF(ruby_exception), "%
|
1107
|
+
rb_raise(CLASS_OF(ruby_exception), "%" PRIsVALUE, rb_str);
|
1093
1108
|
}
|
1094
1109
|
}
|
1095
1110
|
|
@@ -1149,13 +1164,13 @@ static VALUE rb_context_eval_unsafe(VALUE self, VALUE str, VALUE filename) {
|
|
1149
1164
|
HandleScope handle_scope(isolate);
|
1150
1165
|
|
1151
1166
|
Local<String> eval = String::NewFromUtf8(isolate, RSTRING_PTR(str),
|
1152
|
-
NewStringType::kNormal, (
|
1167
|
+
NewStringType::kNormal, RSTRING_LENINT(str)).ToLocalChecked();
|
1153
1168
|
|
1154
1169
|
Local<String> local_filename;
|
1155
1170
|
|
1156
1171
|
if (filename != Qnil) {
|
1157
1172
|
local_filename = String::NewFromUtf8(isolate, RSTRING_PTR(filename),
|
1158
|
-
NewStringType::kNormal, (
|
1173
|
+
NewStringType::kNormal, RSTRING_LENINT(filename)).ToLocalChecked();
|
1159
1174
|
eval_params.filename = &local_filename;
|
1160
1175
|
} else {
|
1161
1176
|
eval_params.filename = NULL;
|
@@ -1279,8 +1294,8 @@ gvl_ruby_callback(void* data) {
|
|
1279
1294
|
VALUE callback_data_value = (VALUE)&callback_data;
|
1280
1295
|
|
1281
1296
|
// TODO: use rb_vrescue2 in Ruby 2.7 and above
|
1282
|
-
result = rb_rescue2(protected_callback, callback_data_value,
|
1283
|
-
rescue_callback, callback_data_value, rb_eException, (VALUE)0);
|
1297
|
+
result = rb_rescue2(MR_METHOD_FUNC(protected_callback), callback_data_value,
|
1298
|
+
MR_METHOD_FUNC(rescue_callback), callback_data_value, rb_eException, (VALUE)0);
|
1284
1299
|
|
1285
1300
|
if(callback_data.failed) {
|
1286
1301
|
rb_iv_set(parent, "@current_exception", result);
|
@@ -1341,7 +1356,7 @@ static VALUE rb_external_function_notify_v8(VALUE self) {
|
|
1341
1356
|
|
1342
1357
|
Local<String> v8_str =
|
1343
1358
|
String::NewFromUtf8(isolate, RSTRING_PTR(name),
|
1344
|
-
NewStringType::kNormal, (
|
1359
|
+
NewStringType::kNormal, RSTRING_LENINT(name))
|
1345
1360
|
.ToLocalChecked();
|
1346
1361
|
|
1347
1362
|
// Note that self (rb_cExternalFunction) is a pure Ruby T_OBJECT,
|
@@ -1361,7 +1376,7 @@ static VALUE rb_external_function_notify_v8(VALUE self) {
|
|
1361
1376
|
Local<String> eval =
|
1362
1377
|
String::NewFromUtf8(isolate, RSTRING_PTR(parent_object_eval),
|
1363
1378
|
NewStringType::kNormal,
|
1364
|
-
(
|
1379
|
+
RSTRING_LENINT(parent_object_eval))
|
1365
1380
|
.ToLocalChecked();
|
1366
1381
|
|
1367
1382
|
MaybeLocal<Script> parsed_script = Script::Compile(context, eval);
|
@@ -1820,23 +1835,15 @@ static VALUE rb_context_call_unsafe(int argc, VALUE *argv, VALUE self) {
|
|
1820
1835
|
if (val.IsEmpty() || !val.ToLocalChecked()->IsFunction()) {
|
1821
1836
|
missingFunction = true;
|
1822
1837
|
} else {
|
1823
|
-
|
1824
1838
|
Local<v8::Function> fun = Local<v8::Function>::Cast(val.ToLocalChecked());
|
1839
|
+
VALUE tmp;
|
1825
1840
|
call.fun = fun;
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
call.argv = (v8::Local<Value> *) malloc(sizeof(void *) * fun_argc);
|
1830
|
-
if (!call.argv) {
|
1831
|
-
return Qnil;
|
1832
|
-
}
|
1833
|
-
for(int i=0; i < fun_argc; i++) {
|
1834
|
-
call.argv[i] = convert_ruby_to_v8(isolate, context, call_argv[i]);
|
1835
|
-
}
|
1841
|
+
call.argv = (v8::Local<Value> *)RB_ALLOCV_N(void *, tmp, call.argc);
|
1842
|
+
for(int i=0; i < call.argc; i++) {
|
1843
|
+
call.argv[i] = convert_ruby_to_v8(isolate, context, call_argv[i]);
|
1836
1844
|
}
|
1837
1845
|
rb_thread_call_without_gvl(nogvl_context_call, &call, unblock_function, &call);
|
1838
|
-
|
1839
|
-
|
1846
|
+
RB_ALLOCV_END(tmp);
|
1840
1847
|
}
|
1841
1848
|
}
|
1842
1849
|
|
data/lib/mini_racer/version.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,9 +128,9 @@ licenses:
|
|
128
128
|
- MIT
|
129
129
|
metadata:
|
130
130
|
bug_tracker_uri: https://github.com/discourse/mini_racer/issues
|
131
|
-
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.6.
|
132
|
-
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.6.
|
133
|
-
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.6.
|
131
|
+
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.6.2/CHANGELOG
|
132
|
+
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.6.2
|
133
|
+
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.6.2
|
134
134
|
post_install_message:
|
135
135
|
rdoc_options: []
|
136
136
|
require_paths:
|