Skip to content
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.

zopfli: fails on non-empty input file #9

Open
cznic opened this issue Oct 13, 2017 · 2 comments
Open

zopfli: fails on non-empty input file #9

cznic opened this issue Oct 13, 2017 · 2 comments
Assignees
Labels

Comments

@cznic
Copy link
Owner

cznic commented Oct 13, 2017

@opennota

jnml@r550:~/src/github.com/google/zopfli$ ls
CONTRIBUTING.md  CONTRIBUTORS  COPYING  Makefile  README  README.zopflipng  src
jnml@r550:~/src/github.com/google/zopfli$ git status 
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
jnml@r550:~/src/github.com/google/zopfli$ touch tmp
jnml@r550:~/src/github.com/google/zopfli$ 99c src/zopfli/*.c -O2 -W -Wall -Wextra -Wno-unused-function -ansi -pedantic -lm -o zopfli && ./zopfli -v tmp
Saving to: tmp.gz
Error: Out of memory. Tried allocating 0 bytes of memory.
jnml@r550:~/src/github.com/google/zopfli$ 99trace ./zopfli -v tmp |& tee trace
jnml@r550:~/src/github.com/google/zopfli$

This looks like a bug in ccir or virtual. I'll try to invstigate later. Feel free to try to find the bug(s) by yourself if you like. The attached trace might be useful in identifying the source of the problem.

trace.zip

@cznic cznic added the bug label Oct 13, 2017
@cznic cznic self-assigned this Oct 13, 2017
cznic pushed a commit to cznic/virtual that referenced this issue Oct 15, 2017
Also, add position info to strace output.

	modified:   cpu.go
	modified:   fcntl_linux_386.go
	modified:   fcntl_linux_amd64.go
	modified:   stdio.go
	modified:   stdlib.go
	modified:   sys_mman_linux.go
	modified:   sys_socket_linux.go
	modified:   sys_stat_linux_386.go
	modified:   sys_stat_linux_amd64.go
	modified:   unistd_linux.go
@cznic
Copy link
Owner Author

cznic commented Oct 15, 2017

@opennota

The C code assumes malloc(0) cannot return NULL, but it can. Anyway, virtual is now truning malloc(0) into malloc(1). We have progrress:

jnml@4670:~/src/github.com/google/zopfli$ ls
CONTRIBUTING.md  CONTRIBUTORS  COPYING  Makefile  README  README.zopflipng  src
jnml@4670:~/src/github.com/google/zopfli$ touch tmp
jnml@4670:~/src/github.com/google/zopfli$ gcc src/zopfli/*.c -O2 -W -Wall -Wextra -Wno-unused-function -ansi -pedantic -lm -o zopfli && ./zopfli -v tmp && hd tmp.gz
Saving to: tmp.gz
Iteration 0: 91 bit
Original Size: 0, Deflate: 2, Compression: inf% Removed
Original Size: 0, Gzip: 20, Compression: inf% Removed
00000000  1f 8b 08 00 00 00 00 00  02 03 03 00 00 00 00 00  |................|
00000010  00 00 00 00                                       |....|
00000014
jnml@4670:~/src/github.com/google/zopfli$ rm -v tmp.gz
removed 'tmp.gz'
jnml@4670:~/src/github.com/google/zopfli$ 99c src/zopfli/*.c -O2 -W -Wall -Wextra -Wno-unused-function -ansi -pedantic -lm -o zopfli && ./zopfli -v tmp && hd tmp.gz
Saving to: tmp.gz
Iteration 0: 91 bit
Original Size: 0, Deflate: 2, Compression: -Inf% Removed
Original Size: 0, Gzip: 20, Compression: -Inf% Removed
00000000  1f 8b 08 00 00 00 00 00  02 03 03 00 00 00 00 00  |................|
00000010  00 00 00 00                                       |....|
00000014
jnml@4670:~/src/github.com/google/zopfli$ 

The program still fails on non-empty input, but that's a different bug.

@cznic cznic changed the title zopfli: fails on empty input file zopfli: fails on non-empty input file Oct 15, 2017
@cznic
Copy link
Owner Author

cznic commented Oct 15, 2017

1-byte file passes:

jnml@4670:~/src/github.com/google/zopfli$ echo -n a > tmp && hd tmp
00000000  61                                                |a|
00000001
jnml@4670:~/src/github.com/google/zopfli$ gcc src/zopfli/*.c -O2 -W -Wall -Wextra -Wno-unused-function -ansi -pedantic -lm -o zopfli && ./zopfli -v tmp && hd tmp.gz
Saving to: tmp.gz
Iteration 0: 101 bit
compressed block size: 2 (0k) (unc: 1)
Original Size: 1, Deflate: 3, Compression: 1844674407370955161600.000000% Removed
Original Size: 1, Gzip: 21, Compression: 1844674407370955161600.000000% Removed
00000000  1f 8b 08 00 00 00 00 00  02 03 4b 04 00 43 be b7  |..........K..C..|
00000010  e8 01 00 00 00                                    |.....|
00000015
jnml@4670:~/src/github.com/google/zopfli$ rm -v tmp.gz
removed 'tmp.gz'
jnml@4670:~/src/github.com/google/zopfli$ 99c src/zopfli/*.c -O2 -W -Wall -Wextra -Wno-unused-function -ansi -pedantic -lm -o zopfli && ./zopfli -v tmp && hd tmp.gz
Saving to: tmp.gz
Iteration 0: 101 bit
compressed block size: 2 (0k) (unc: 1)
Original Size: 1, Deflate: 3, Compression: -200.000000% Removed
Original Size: 1, Gzip: 21, Compression: -2000.000000% Removed
00000000  1f 8b 08 00 00 00 00 00  02 03 4b 04 00 43 be b7  |..........K..C..|
00000010  e8 01 00 00 00                                    |.....|
00000015
jnml@4670:~/src/github.com/google/zopfli$ 

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant