mini_racer 0.17.0.pre4 → 0.17.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/ext/mini_racer_extension/mini_racer_extension.cc +103 -76
- 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: bd92c74de497ca8b317cb32e02345d204081c50ef44c11a61b0cfef3e32e2cff
|
4
|
+
data.tar.gz: b2074ffd330b91006c28e0d6b9a4b346a9a0e6d9de30cffd83bb426189262c4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36dd26be30d9e22f5c227f8864a03e6f55224b9265799d604bf933b7458ead17960fef48de19a8d33f6c3c1578f83740c9c8c704541beb7964f6de23f4ec1fb9
|
7
|
+
data.tar.gz: 89067b89d2dbd6cf7b2af79991f30e53c6df8cc7d08e35623f730eb7010c287ccb98a29444375a7593f4494e11ad25b2c74a3d0b73ce104f7fc64edf22fb9e7e
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
- 0.17.0.pre5 - 30-09-2024
|
2
|
+
|
3
|
+
- Handle segfault from JSON.stringify
|
4
|
+
- Fix segfaults around symbol conversion
|
5
|
+
- Fix crash on invalid date object
|
6
|
+
|
7
|
+
|
1
8
|
- 0.17.0.pre4 - 18-09-2024
|
2
9
|
|
3
10
|
- Attempt to change compilation flags to disable strict aliasing to see if it resolves stability issues
|
@@ -429,14 +429,17 @@ static void prepare_result(MaybeLocal<Value> v8res,
|
|
429
429
|
Local<Object> object = local_value->ToObject(context).ToLocalChecked();
|
430
430
|
const unsigned argc = 1;
|
431
431
|
Local<Value> argv[argc] = { object };
|
432
|
-
MaybeLocal<Value>
|
432
|
+
MaybeLocal<Value> maybe_json = stringify->Call(context, JSON, argc, argv);
|
433
|
+
Local<Value> json;
|
433
434
|
|
434
|
-
if (
|
435
|
+
if (!maybe_json.ToLocal(&json)) {
|
435
436
|
evalRes.executed = false;
|
436
437
|
} else {
|
437
|
-
|
438
|
+
// JSON.stringify() returns undefined for inputs that
|
439
|
+
// are exotic objects, like WASM function or string refs
|
440
|
+
evalRes.json = !json->IsUndefined();
|
438
441
|
Persistent<Value>* persistent = new Persistent<Value>();
|
439
|
-
persistent->Reset(isolate, json
|
442
|
+
persistent->Reset(isolate, json);
|
440
443
|
evalRes.value = persistent;
|
441
444
|
}
|
442
445
|
}
|
@@ -565,6 +568,7 @@ static VALUE convert_v8_to_ruby(Isolate* isolate, Local<Context> context,
|
|
565
568
|
|
566
569
|
Isolate::Scope isolate_scope(isolate);
|
567
570
|
HandleScope scope(isolate);
|
571
|
+
Context::Scope context_scope(context);
|
568
572
|
|
569
573
|
StackCounter stackCounter(isolate);
|
570
574
|
|
@@ -586,10 +590,6 @@ static VALUE convert_v8_to_ruby(Isolate* isolate, Local<Context> context,
|
|
586
590
|
return INT2FIX(value->Int32Value(context).ToChecked());
|
587
591
|
}
|
588
592
|
|
589
|
-
if (value->IsNumber()) {
|
590
|
-
return rb_float_new(value->NumberValue(context).ToChecked());
|
591
|
-
}
|
592
|
-
|
593
593
|
if (value->IsTrue()) {
|
594
594
|
return Qtrue;
|
595
595
|
}
|
@@ -598,81 +598,108 @@ static VALUE convert_v8_to_ruby(Isolate* isolate, Local<Context> context,
|
|
598
598
|
return Qfalse;
|
599
599
|
}
|
600
600
|
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
Local<Object> object = value->ToObject(context).ToLocalChecked();
|
635
|
-
auto maybe_props = object->GetOwnPropertyNames(context);
|
636
|
-
if (!maybe_props.IsEmpty()) {
|
637
|
-
Local<Array> props = maybe_props.ToLocalChecked();
|
638
|
-
for(uint32_t i=0; i < props->Length(); i++) {
|
639
|
-
MaybeLocal<Value> key = props->Get(context, i);
|
640
|
-
if (key.IsEmpty()) {
|
641
|
-
return rb_funcall(rb_cFailedV8Conversion, rb_intern("new"), 1, rb_str_new2(""));
|
642
|
-
}
|
643
|
-
VALUE rb_key = convert_v8_to_ruby(isolate, context, key.ToLocalChecked());
|
644
|
-
|
645
|
-
MaybeLocal<Value> prop_value = object->Get(context, key.ToLocalChecked());
|
646
|
-
// this may have failed due to Get raising
|
647
|
-
if (prop_value.IsEmpty() || trycatch.HasCaught()) {
|
648
|
-
return new_empty_failed_conv_obj();
|
649
|
-
}
|
650
|
-
|
651
|
-
VALUE rb_value = convert_v8_to_ruby(
|
652
|
-
isolate, context, prop_value.ToLocalChecked());
|
653
|
-
rb_hash_aset(rb_hash, rb_key, rb_value);
|
601
|
+
struct State {
|
602
|
+
Isolate* isolate;
|
603
|
+
Local<Value> value;
|
604
|
+
Local<Context> context;
|
605
|
+
} state = {isolate, value, context};
|
606
|
+
|
607
|
+
// calls to rb_*() functions can raise exceptions and longjmp,
|
608
|
+
// and therefore must be inside this protected block
|
609
|
+
auto can_raise = [](VALUE arg) -> VALUE {
|
610
|
+
State* state =
|
611
|
+
reinterpret_cast<State*>(static_cast<uintptr_t>(RB_NUM2ULL(arg)));
|
612
|
+
Isolate* isolate = state->isolate;
|
613
|
+
Local<Value> value = state->value;
|
614
|
+
Local<Context> context = state->context;
|
615
|
+
|
616
|
+
if (value->IsNumber()) {
|
617
|
+
return rb_float_new(value->NumberValue(context).ToChecked());
|
618
|
+
}
|
619
|
+
|
620
|
+
if (value->IsArray()) {
|
621
|
+
VALUE rb_array = rb_ary_new();
|
622
|
+
Local<Array> arr = Local<Array>::Cast(value);
|
623
|
+
for(uint32_t i = 0; i < arr->Length(); i++) {
|
624
|
+
MaybeLocal<Value> element = arr->Get(context, i);
|
625
|
+
if (element.IsEmpty()) {
|
626
|
+
continue;
|
627
|
+
}
|
628
|
+
VALUE rb_elem = convert_v8_to_ruby(isolate, context, element.ToLocalChecked());
|
629
|
+
if (rb_funcall(rb_elem, rb_intern("class"), 0) == rb_cFailedV8Conversion) {
|
630
|
+
return rb_elem;
|
631
|
+
}
|
632
|
+
rb_ary_push(rb_array, rb_elem);
|
654
633
|
}
|
634
|
+
return rb_array;
|
655
635
|
}
|
656
|
-
return rb_hash;
|
657
|
-
}
|
658
636
|
|
659
|
-
|
660
|
-
|
661
|
-
|
637
|
+
if (value->IsFunction()){
|
638
|
+
return rb_funcall(rb_cJavaScriptFunction, rb_intern("new"), 0);
|
639
|
+
}
|
662
640
|
|
663
|
-
|
641
|
+
if (value->IsDate()){
|
642
|
+
double ts = Local<Date>::Cast(value)->ValueOf();
|
643
|
+
double secs = ts/1000;
|
644
|
+
long nanos = round((secs - floor(secs)) * 1000000);
|
664
645
|
|
665
|
-
|
666
|
-
|
646
|
+
return rb_time_new(secs, nanos);
|
647
|
+
}
|
667
648
|
|
668
|
-
|
649
|
+
if (value->IsObject()) {
|
650
|
+
VALUE rb_hash = rb_hash_new();
|
651
|
+
TryCatch trycatch(isolate);
|
652
|
+
|
653
|
+
Local<Object> object = value->ToObject(context).ToLocalChecked();
|
654
|
+
auto maybe_props = object->GetOwnPropertyNames(context);
|
655
|
+
if (!maybe_props.IsEmpty()) {
|
656
|
+
Local<Array> props = maybe_props.ToLocalChecked();
|
657
|
+
for (uint32_t i = 0; i < props->Length(); i++) {
|
658
|
+
MaybeLocal<Value> key = props->Get(context, i);
|
659
|
+
if (key.IsEmpty()) {
|
660
|
+
return rb_funcall(rb_cFailedV8Conversion, rb_intern("new"), 1, rb_str_new2(""));
|
661
|
+
}
|
662
|
+
VALUE rb_key = convert_v8_to_ruby(isolate, context, key.ToLocalChecked());
|
669
663
|
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
664
|
+
MaybeLocal<Value> prop_value = object->Get(context, key.ToLocalChecked());
|
665
|
+
// this may have failed due to Get raising
|
666
|
+
if (prop_value.IsEmpty() || trycatch.HasCaught()) {
|
667
|
+
return new_empty_failed_conv_obj();
|
668
|
+
}
|
669
|
+
|
670
|
+
VALUE rb_value = convert_v8_to_ruby(
|
671
|
+
isolate, context, prop_value.ToLocalChecked());
|
672
|
+
rb_hash_aset(rb_hash, rb_key, rb_value);
|
673
|
+
}
|
674
|
+
}
|
675
|
+
return rb_hash;
|
676
|
+
}
|
677
|
+
|
678
|
+
if (value->IsSymbol()) {
|
679
|
+
Local<Symbol> symbol = Local<Symbol>::Cast(value);
|
680
|
+
Local<Value> description = symbol->Description(isolate);
|
681
|
+
v8::String::Utf8Value symbol_name(isolate, description);
|
682
|
+
|
683
|
+
VALUE str_symbol = rb_utf8_str_new(*symbol_name, symbol_name.length());
|
684
|
+
|
685
|
+
return rb_str_intern(str_symbol);
|
686
|
+
}
|
687
|
+
|
688
|
+
MaybeLocal<String> rstr_maybe = value->ToString(context);
|
689
|
+
|
690
|
+
if (rstr_maybe.IsEmpty()) {
|
691
|
+
return Qnil;
|
692
|
+
} else {
|
693
|
+
Local<String> rstr = rstr_maybe.ToLocalChecked();
|
694
|
+
return rb_utf8_str_new(*String::Utf8Value(isolate, rstr), rstr->Utf8Length(isolate));
|
695
|
+
}
|
696
|
+
};
|
697
|
+
|
698
|
+
// this is kind of slow because RB_ULL2NUM allocs when the pointer
|
699
|
+
// doesn't fit in a fixnum but yolo'ing and reinterpret_casting the
|
700
|
+
// pointer to a VALUE is probably not very sound
|
701
|
+
VALUE arg = RB_ULL2NUM(reinterpret_cast<uintptr_t>(&state));
|
702
|
+
return rb_protect(can_raise, arg, nullptr);
|
676
703
|
}
|
677
704
|
|
678
705
|
static VALUE convert_v8_to_ruby(Isolate* isolate,
|
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.17.0.
|
4
|
+
version: 0.17.0.pre5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,9 +119,9 @@ licenses:
|
|
119
119
|
- MIT
|
120
120
|
metadata:
|
121
121
|
bug_tracker_uri: https://github.com/discourse/mini_racer/issues
|
122
|
-
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.17.0.
|
123
|
-
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.17.0.
|
124
|
-
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.17.0.
|
122
|
+
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.17.0.pre5/CHANGELOG
|
123
|
+
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.17.0.pre5
|
124
|
+
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.17.0.pre5
|
125
125
|
post_install_message:
|
126
126
|
rdoc_options: []
|
127
127
|
require_paths:
|