在Botan上用Argon2生成hash会产生垃圾数据和0xC0000005: Access violation reading location 0x0000000100000000

Generating hash with Argon2 on Botan results in garbage data and 0xC0000005: Access violation reading location 0x0000000100000000

我正在尝试使用 C++ 加密库 Botan 对密码进行哈希处理。我尝试使用以下代码测试库:

#include <iostream>
#include <string>
#include <botan/argon2.h>
#include <botan/system_rng.h>

int main() {
    Botan::System_RNG rng;
    std::string password = "cool_password";

    std::string generated_hash = Botan::argon2_generate_pwhash(password.c_str(), 
    password.length(), rng, 1, 4000, 1); // crash occurs here

    std::cout << generated_hash << "\n";
}

但是代码要么打印了垃圾数据,要么给我一个运行时错误: Unhandled exception at 0x00007FFEF11825E0 (ucrtbased.dll) in app.exe: 0xC0000005: Access violation reading location 0x0000000100000000.

我该怎么办?使用其他散列方法,例如 Botan::generate_bcrypt() 也会导致同样的错误。

经过 4 个小时的痛苦排查和用不同的编译器一遍又一遍地重建库,我发现如果“解决方案配置”没有设置为“发布”而不是“调试”,Botan 将无法正常工作Visual Studio.