Skip to content
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

[DivByZeroDefect] when attempting to use gzip on i386 application for Windows #94

Open
SecDbg opened this issue Jan 6, 2025 · 1 comment

Comments

@SecDbg
Copy link

SecDbg commented Jan 6, 2025

Hey, I was trying to use puppy as a HTTP client in an x86 application, but I noticed that I was getting a [DivByZeroDefect]

It seems that this is an issue with zippy itself as the error points to C:\Users\Admin\.nimble\pkgs2\zippy-0.10.16-da3bb5ea388f980babcc29760348e2899d29a639\zippy\gzip.nim(76) uncompressGzip

I have tried running the example HTTP client in the repo, but that likewise fails on i386.

This is the error I'm getting:

D:\Testing-Zippy-i386\main.nim(9) main
C:\Users\Admin\.nimble\pkgs2\zippy-0.10.16-da3bb5ea388f980babcc29760348e2899d29a639\zippy.nim(171) uncompress
C:\Users\Admin\.nimble\pkgs2\zippy-0.10.16-da3bb5ea388f980babcc29760348e2899d29a639\zippy.nim(115) uncompress
C:\Users\Admin\.nimble\pkgs2\zippy-0.10.16-da3bb5ea388f980babcc29760348e2899d29a639\zippy.nim(128) uncompress
C:\Users\Admin\.nimble\pkgs2\zippy-0.10.16-da3bb5ea388f980babcc29760348e2899d29a639\zippy\gzip.nim(76) uncompressGzip
C:\nim-2.2.0\lib\system\fatal.nim(53) sysFatal
Error: unhandled exception: division by zero [DivByZeroDefect]
Error: execution of an external program failed: 'D:\Testing-Zippy-i386\main.exe'
PS D:\Testing-Zippy-i386>

The command I'm using to compile for 32-bit is nim c --cpu:i386 --gcc.path=C:\mingw32\bin -r .\main.nim

I looked through some earlier push requests and found a supposed fix for 32-bit that was pushed, but that didn't seem to fix the issue.
I'm using Zippy 0.10.16 (as installed through Nimble).

Thanks in advance :D

@SecDbg
Copy link
Author

SecDbg commented Jan 6, 2025

It seems to work after I changed 32 to 31 on line 76:

  if isize != (dst.len mod (1 shl 31)).uint32:

I'm not really sure if this is the correct fix? I'll try use the tests to see if everything works. I don't really have any experience with compression per se.

Looks like all tests passed (using nimble test)

   Success: Execution finished
   Success: All tests passed

@SecDbg SecDbg mentioned this issue Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant