-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request help, Two same code behaves differently, leading to incorrect decompression results. #330
Comments
I'm not a code contributor, and I'm assuming you already tested this, but since I recently had a similar problem caused by something external in the end:
If miniz version and archive really are the same, other code causing memory corruption that spills over seems like not an unlikely culprit. I'm not saying it can't be miniz's fault, but you would perhaps wanna rule out such other causes if you haven't yet. Sorry if this isn't helpful. |
ell1e, Thank you very much for your suggestions. 1,The two projects I opened are using the same file, so the file is consistent. From my preliminary analysis, this error might be related to our compilation environment or multithreading. In my project M, if I call the function in the start of main(), miniz can run normally and produce the expected results. However, if I call it during the program's execution, this issue always occurs. Therefore, I suspect that it might be related to multithreading. However, even after adding synchronization to these functions, the error persists. When I run this program on macOS, I have never encountered this error. Therefore, I also suspect that the issue might be related to the compilation environment. On Windows 10, I used MinGW-W64-builds-4.3.5 64-bit version (gcc (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0), and later I tried the 32-bit version of MinGW-W64-builds-4.3.5, which resulted in the same error. Then, I used the MinGW version bundled with JetBrains (gcc (GCC) 11.2.0), and the program worked correctly after compilation. Therefore, I am unsure whether attributing this issue to the compilation environment is correct. |
The problem is NOT produced by miniz. This is the conclusion of my new test , MinGW take the blame for the error, Detailed Explanation Test code:
|
I am using miniz in a project M, and it works great, but I encountered an issue that confuses me. The problem is that when I try to decompress a file in project M, it fails. However, when I place this code snippet in a separate test code T, it works perfectly. When this code is placed in project M, the decompression CRC32 check fails. I have debugged both projects simultaneously, trying to trace the code step by step and compare the execution results. I found that at one point, the return values differ between the test code T and the project M code, which eventually leads to incorrect decompressed data.
Below are several screenshots. The first three images show the environment variable values in both IDEs before executing the following line of code:
After executing this line of code, cur_ofs = 31 in my project code, while cur_ofs = 30 in the test code.
The last two images show that during execution, the test code T performs a SEEK operation, whereas in my project M, because file_ofs equals 31, no SEEK operation is performed. Consequently, the final results are different. In project M, the bytes read are off by one byte, as if the reading position is shifted forward by one byte compared to the correct result.
In project M, this function is frequently used to read some class files or resource files from a JAR.
the caller function, same as Project M and Project T
The text was updated successfully, but these errors were encountered: