Null pointer dereference error only on Android

  android, android-ndk, c++, ios

When using my library on Android I get a null pointer dereference error when calling the lock function on a unique_pointer. I do not get this error when using it on iOS. Snippets of the troubled code is as follows:

foo.hpp

std::mutex bundlesMutex;

foo.cpp

void somefunction(std::uint8_t blah) {
    std::unique_lock<std::mutex> bundlesLock(bundlesMutex, std::defer_lock);

    //do stuff

    bundlesLock.lock(); //crash happens here

    //do other stuff

    bundlesLock.unlock();
}

Any ideas? I looked around hard and debugged, but am pretty stumped on why this is happening. Code seems valid, unless it’s something on the platforms.

Source: Windows Questions C++

LEAVE A COMMENT