My C++ code, push a string to mystack
#include <iostream>
#include <stack>
#include "NativeLogger.h"
std::stack<std::string> mystack;
JNIEXPORT void JNICALL
Java_NativeLogger_push(JNIEnv *env, jobject obj,jstring name)
{
std::string s = env->GetStringUTFChars(name, 0);
mystack.push(s);
return;
}
JNIEXPORT void JNICALL
Java_NativeLogger_pop(JNIEnv *env, jobject obj)
{
mystack.pop();
return;
}
I got follow crash report when runs with Java, any idea how to fix it?
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x00007f29421a0207, pid=18007, tid=0x00007f2942d3e700
JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01) Java VM: Java HotSpot(TM) 64-Bit Server VM (25.144-b01 mixed mode linux-amd64 compressed oops) Problematic frame: C [libc.so.6+0x97207] __libc_malloc+0x197