Android JNI 崩溃 (SIGABRT)

Android JNI crashes (SIGABRT)

我有一个 Android Kotlin 应用程序调用一个简单的 JNI 函数,后者调用一个 C++ 单例。 当我调用 JNI 函数时出现崩溃 (SIGABRT)。我看不出有什么问题...

Kotlin 代码:

stopProcessing() // Calls stopProcessing JNI function

JNI 代码:

extern "C"
JNIEXPORT void JNICALL
Java_com_tb_of_1ir_MainActivity_stopProcessing(JNIEnv *env, jobject thiz) {
    static auto a = MySingleton::get();
    a->stopProcessing();
}

C++代码:

[[noreturn]] void stopProcessing() {
}

目前C++代码中没有任何东西,但即使里面有东西(任何东西)也有同样的问题。

谢谢!

编辑:

单例代码:

#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;

我不得不删除 C++ 单例中的 [[noreturn]] 语句 class。

感谢 Richard Critten 发表评论(添加答案,我会接受)。