Invoking V8::Initialize will crash with Fatal signal 6 (SIGABRT) error

864 views
Skip to first unread message

Kazuya Hiruma

unread,
May 20, 2022, 11:19:42 AM5/20/22
to v8-users
Recently, I'm trying to use V8 in my Android app with libv8_monolith.a.

I buillt it on Ubuntu on WSL successfly. I use it in my app with set up code below.

```
using namespace v8;
Isolate* isolate_;
Global<Context> context_;
Isolate::CreateParams create_params;
std::unique_ptr<Platform> platform_;


void initV8()
{
    V8::InitializeICU();

    platform_ = v8::platform::NewDefaultPlatform();
    V8::InitializePlatform(platform_.get());
    
    V8::Initialize(); // Here will crash!
}

extern "C" JNIEXPORT jstring JNICALL
Java_com_edo_v8api_MainActivity_stringFromJNI(
        JNIEnv* env,
        jobject /* this */) {
    std::string hello = "Hello from C++";
   
    initV8();

    return env->NewStringUTF(hello.c_str());
}

```

Then, I got below error.

-----------------------------------------------------------------------------------------------
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 27338 (com.edo.v8api), pid 27338 (com.edo.v8api)
-----------------------------------------------------------------------------------------------

I'm not sure why this error was occurred. Should I do more but I put v8_monolith.a into the Android project? I imported libv8_monolith.a only.

Kazuya Hiruma

unread,
May 22, 2022, 6:21:46 AM5/22/22
to v8-users
I found the problem out myself.

I had to add cpp flags to build.gradle like below.

```
externalNativeBuild {
    cmake {
        cppFlags "-DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH"
    }
}
```

I also got an error below.

```
2022-05-22 18:50:30.448 24553-24553/com.example.v8api E/v8: Embedder-vs-V8 build configuration mismatch. On embedder side pointer compression is DISABLED while on V8 side it's ENABLED.
```

2022年5月21日土曜日 0:19:42 UTC+9 Kazuya Hiruma:
Reply all
Reply to author
Forward
0 new messages