我在我的代码中遇到了一个相当奇怪的崩溃,我不确定是什么导致了它。我正在尝试在我的c++代码中使用PhysFS。下面的代码是一个类的一部分,Visual Studio2017告诉我,崩溃出现在PHYSFS_mount()中,随后出现在EnterCriticalSection()中,据我所知,这与互斥有关。现在,根据我的理解,这应该是正确的(请注意,main首先调用initArchives() )
physfs_initialized = false;
...
void scope::parse_archive(const std::string& archive_path, const std::string& path_in_archive)
{
assert(physfs_initialized);
m_archivePath = archive_path;
m_relativeArchivePath = path_in_archive.substr(1);
//fsx = std::filesystem or std::expiremental::filesystem whatever floats your boat
if(exists(fsx::path(archive_path))) return;
if(!PHYSFS_mount(m_archivePath.c_str(),"",0)) return;
const auto file = PHYSFS_openRead(m_relativeArchivePath.c_str());
if(file) m_isValid = true;
PHYSFS_close(file);
PHYSFS_unmount(m_archivePath.c_str());
}
...
void initArchives(char ** argv)
{
if (!PHYSFS_init(argv[0])) physfs_initialized = true;
//a bit of ugly syntax because of the need to consume the return type
atexit([]() {PHYSFS_deinit(); });
}坠机显然出现在这里
int __PHYSFS_platformGrabMutex(void *mutex)
{
EnterCriticalSection((LPCRITICAL_SECTION) mutex); // <-- here
return 1;
} /* __PHYSFS_platformGrabMutex */我是不是做错了什么?这是库的问题,还是我的操作系统的问题?在PhysFS的构建步骤中,有什么我遗漏的东西吗?
编辑:我注意到我读错了PHYSFS_init()的返回值,但是现在我更困惑了,因为PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())返回“没有错误”,这是怎么回事?
发布于 2019-03-09 23:45:23
显然,关于Windows10的PhysFS中存在一个错误。这将阻止正确执行PHYSFS_init(),将phsyfs_platform_windows.c的第578行改为
rc = pGetDir(accessToken, NULL, &psize);
库的重新编译为我解决了这个问题:/
https://hg.icculus.org/icculus/physfs/rev/ece6769c0676
https://discourse.libsdl.org/t/resolved-physfs-exception-thrown/25697/11
https://stackoverflow.com/questions/55078623
复制相似问题