I have an Android Kotlin application that calls a simple JNI function, the latter calling a C++ singleton. There is a crash (SIGABRT) when I call the JNI function. I can't see what is wrong...
Kotlin code :
stopProcessing() // Calls stopProcessing JNI function
JNI code :
extern "C"
JNIEXPORT void JNICALL
Java_com_tb_of_1ir_MainActivity_stopProcessing(JNIEnv *env, jobject thiz) {
static auto a = MySingleton::get();
a->stopProcessing();
}
C++ code :
[[noreturn]] void stopProcessing() {
}
There is nothing in the C++ code for now, but even if something inside (anything) there is the same problem.
Thanks !
Edit :
The singleton code :
#include "MySingleton.h"
#include <iostream>
#include <unistd.h>
#include <cstdlib>
#include <signal.h>
#include <chrono>
#include <thread>
#include <bitset>
class MySingleton {
private:
static MySingleton *singleton;
explicit MySingleton() {
src_string = "The default string value";
}
public:
static MySingleton *get() {
if (singleton == nullptr)
singleton = new MySingleton();
return singleton;
}
bool MySingletonStarted = false;
bool stop = false;
std::string dest_string, src_string;
[[noreturn]] void startProcessing() {
stop = false;
MySingletonStarted = true;
while(!stop) {
dest_string = src_string;
}
}
void stopProcessing() {
}
};
MySingleton *MySingleton::singleton = nullptr;