在Windows RT ARM平台上的SQLite3中崩溃

Crash in SQLite3 on Windows RT ARM platform

本文关键字:SQLite3 崩溃 平台 Windows RT ARM      更新时间:2023-10-16

我目前正在通过Visual Studio 2012中的扩展和更新管理器使用SQLite3 v3.7.14下载。当我为 Win32 编译时,它可以工作,但当我在 ARM 上编译和运行时,它不起作用。每当我尝试设置sqlite3_temp_directory时,它都会崩溃。我觉得我正在遵循这里的文档(http://www.sqlite.org/c3ref/temp_directory.html)。

void init()
{
    // Set the temporary directory for sqlite prior to opening the database
    LPCWSTR zPath = Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data();
    char zPathBuf[MAX_PATH + 1];
    memset(zPathBuf, 0, sizeof(zPathBuf));
    WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf), NULL, NULL);
    sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf); // CRASHES HERE ON WINRT
    auto localDataPath = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
    std::wstring path(localDataPath->Data());
    path += L"\database.sql";
    sqlite3_open16(path.c_str(), &m_DB);
}

想知道我是否错过了什么?我不确定如何调试这个,也找不到任何在 WinRT 上使用 SQLite3 或正确使用sqlite3_temp_directory的好例子。

更新:

事实证明,如果我包含原始 sqlite3.h/.c 文件绕过官方预编译的 .lib/.dll 文件,上面的代码会按预期工作。

SQLite3 团队告诉我确实存在问题。问题本身要么在SQLite3代码库中,要么在Microsoft MSVC编译器中,他们正在积极努力寻找解决方案。

事实证明,问题仅在启用优化时发生,罪魁祸首是/Og 开关。您可以暂时禁用构建优化来解决此问题。