Skip to content

Access violation opening an Archive on Windows #924

Closed

Description

WARNING: I don't know much about Windows so I might be doing everything wrong.

Trying to use the nightly DLL, I am getting Access Violation (and thus crash) upon opening a ZIM file.

Here's my reprocase.

#include <iostream>
#include <fstream>
#include <zim/archive.h>
using namespace std;

inline bool exists (const std::string name) {
    ifstream f(name.c_str());
    return f.good();
}

int main()
{
    string filename = string("test.zim");
    if (!exists(filename)) {
        cout << "BAD filename" << filename << "..." << endl;
        return 2;
    } else {
        cout << "About to open existing file: " << filename << "..." << endl;
    }
    
    zim::Archive zim = zim::Archive(filename);
    cout << "Opened!" << endl;
    return 0;
}

It requires any ZIM file named test.zim in cwd. I am using this one

here's how I build and run (I have Visual Studio Built Tools 2022 installed and used vcvars64.bat in the shell to target 64b build –zim-9.dll is 64b).

cl /EHsc /Iinclude repro.cpp /link libzim/zim.lib /out:rlz\tester.exe

cd rlz
tester.exe
echo Exit Code is %errorlevel%
cd ..

libzim folder contains both zim.lib and zim-9.dll; include folder contains the zim subfolder. rlz folder contains the runtime stuff: icudt73.dll, icuin73.dll, icuuc73.dll, test.zim, tester.exe, zim-9.dll

Using WinDbg, I get some insights of what happens:

Microsoft (R) Windows Debugger Version 10.0.27668.1000 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: C:\Users\reg\python-libzim\rlz\tester.exe
Starting directory: C:\Users\reg\python-libzim\rlz

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff7`48be0000 00007ff7`48c1f000   tester.exe
ModLoad: 00007ffd`9f410000 00007ffd`9f627000   ntdll.dll
ModLoad: 00007ffd`9f130000 00007ffd`9f1f4000   C:\Windows\System32\KERNEL32.DLL
ModLoad: 00007ffd`9c730000 00007ffd`9cadd000   C:\Windows\System32\KERNELBASE.dll
ModLoad: 00007ffd`99820000 00007ffd`998b7000   C:\Windows\SYSTEM32\apphelp.dll
ModLoad: 00007ffd`2f660000 00007ffd`2fac7000   C:\Users\reg\python-libzim\rlz\zim-9.dll
ModLoad: 00007ffd`9dc60000 00007ffd`9dd74000   C:\Windows\System32\RPCRT4.dll
ModLoad: 00007ffd`9d360000 00007ffd`9d3d1000   C:\Windows\System32\WS2_32.dll
ModLoad: 00007ffd`96a20000 00007ffd`96a54000   C:\Windows\SYSTEM32\WINMM.dll
ModLoad: 00007ffd`9cd70000 00007ffd`9ce81000   C:\Windows\System32\ucrtbase.dll
ModLoad: 00007ffd`2a180000 00007ffd`2a478000   C:\Users\reg\python-libzim\rlz\icuin73.dll
ModLoad: 00007ffd`31300000 00007ffd`31536000   C:\Users\reg\python-libzim\rlz\icuuc73.dll
ModLoad: 00007ffd`9dd80000 00007ffd`9de32000   C:\Windows\System32\ADVAPI32.dll
ModLoad: 00007ffd`9e530000 00007ffd`9e5d7000   C:\Windows\System32\msvcrt.dll
ModLoad: 00007ffd`9d2b0000 00007ffd`9d359000   C:\Windows\System32\sechost.dll
ModLoad: 00007ffd`9ce90000 00007ffd`9ceb8000   C:\Windows\System32\bcrypt.dll
ModLoad: 00007ffd`47090000 00007ffd`47172000   C:\Windows\SYSTEM32\MSVCP140D.dll
ModLoad: 00007ffd`75690000 00007ffd`756be000   C:\Windows\SYSTEM32\VCRUNTIME140D.dll
ModLoad: 00007ffd`88b90000 00007ffd`88b9f000   C:\Windows\SYSTEM32\VCRUNTIME140_1D.dll
ModLoad: 00007ffd`29f50000 00007ffd`2a171000   C:\Windows\SYSTEM32\ucrtbased.dll
ModLoad: 00007ffd`953a0000 00007ffd`953ac000   C:\Windows\SYSTEM32\VCRUNTIME140_1.dll
ModLoad: 00007ffd`92310000 00007ffd`9232e000   C:\Windows\SYSTEM32\VCRUNTIME140.dll
ModLoad: 00000256`0da70000 00000256`0f8fe000   C:\Users\reg\python-libzim\rlz\icudt73.dll
ModLoad: 00007ffd`65ef0000 00007ffd`65f7d000   C:\Windows\SYSTEM32\MSVCP140.dll
ModLoad: 00000256`0da70000 00000256`0f8fe000   C:\Users\reg\python-libzim\rlz\icudt73.dll
(2440.1904): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ffd`9f4ebed4 cc              int     3
0:000> g
(2440.1904): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
VCRUNTIME140D!memcpy+0x126:
00007ffd`756afd36 f30f6f0a        movdqu  xmm1,xmmword ptr [rdx] ds:00000000`00000000=????????????????????????????????
Screenshot 2024-08-28 at 12 37 32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions