PhysFS_init() returns non-zero with error: "no error"
PhysFS_init() returns non-zero with error: "no error"
我在我的代码中遇到了一次相当奇怪的崩溃,我不确定是什么原因造成的。我试图在我的 C++ 代码中使用 PhysFS。下面的代码是 class 和 Visual Studio 2017 的一部分,告诉我崩溃出现在 PHYSFS_mount()
中,随后出现在 EnterCriticalSection()
中,据我所知,这与互斥体有关.现在根据我的理解,这应该是正确的(注意主要调用 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 */
我是不是做错了什么?这是图书馆的问题还是我的 OS 的问题?我错过了 PhysFS 的构建步骤中的某些内容吗?
编辑:我注意到我读错了 PHYSFS_init() 的 return 值,但是现在我更加困惑 PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
returns "no error",这是怎么回事?
显然 PhysFS 中存在关于 Windows 10 的错误。这会阻止 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
我在我的代码中遇到了一次相当奇怪的崩溃,我不确定是什么原因造成的。我试图在我的 C++ 代码中使用 PhysFS。下面的代码是 class 和 Visual Studio 2017 的一部分,告诉我崩溃出现在 PHYSFS_mount()
中,随后出现在 EnterCriticalSection()
中,据我所知,这与互斥体有关.现在根据我的理解,这应该是正确的(注意主要调用 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 */
我是不是做错了什么?这是图书馆的问题还是我的 OS 的问题?我错过了 PhysFS 的构建步骤中的某些内容吗?
编辑:我注意到我读错了 PHYSFS_init() 的 return 值,但是现在我更加困惑 PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
returns "no error",这是怎么回事?
显然 PhysFS 中存在关于 Windows 10 的错误。这会阻止 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