custom code blows up when printing output of v8::JSON::Stringify

22 views
Skip to first unread message

Jeff Greer

unread,
Dec 13, 2023, 9:25:55 PM12/13/23
to v8-dev
I have a set of static configuration properties that are exposed. These properties are set to defaults in my c++ code. They can be changed in a Javascript script. String and integer types seem to work correctly, but when I have bool data things go south quickly. When the bool data is set to 'true' the program finishes but the bool properties do not appear in the contents of v8::JSON::Stringify. When the bool data is set to 'false' the program blows up if the configuration object is printed using my custom console.logging functions.

        if(value->IsObject()) {
            auto json_string_value = v8::JSON::Stringify(isolate->GetCurrentContext(), value);
std::string string_value = slim::utilities::v8StringToString(isolate, json_string_value.ToLocalChecked());
        }


#
# Fatal error in , line 0
# Check failed: IsJSReceiver(*object).
#
#
#
#FailureMessage Object: 0x7ffe21df5200
==== C stack trace ===============================

    slim(v8::base::debug::StackTrace::StackTrace()+0x13) [0x564d397952e3]
    slim(+0x96a6bb) [0x564d38ddb6bb]
    slim(V8_Fatal(char const*, ...)+0x145) [0x564d3978c195]
    slim(v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<true>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>)+0x1c4c) [0x564d38ffa66c]
    slim(v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>)+0xd6a) [0x564d38ff5bda]
    slim(v8::internal::JsonStringifier::Stringify(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>)+0x76) [0x564d38fef7f6]
    slim(v8::internal::JsonStringify(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>)+0x4b) [0x564d38fef6fb]
    slim(v8::JSON::Stringify(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::String>)+0xe1) [0x564d38deca61]
    /home/greergan/.local/bin/../lib/slim/console.so(slim::console::local_print(v8::FunctionCallbackInfo<v8::Value> const&, slim::console::Configuration*)+0x43d) [0x7f1334ef9b1d]
    /home/greergan/.local/bin/../lib/slim/console.so(slim::console::info(v8::FunctionCallbackInfo<v8::Value> const&)+0x5b) [0x7f1334efa4bb]
    slim(+0x115d253) [0x564d395ce253]
Trace/breakpoint trap (core dumped)
Reply all
Reply to author
Forward
0 new messages