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

huff0: provide asm implementation of Decompress1X #595

Closed
WojciechMula opened this issue May 13, 2022 · 8 comments
Closed

huff0: provide asm implementation of Decompress1X #595

WojciechMula opened this issue May 13, 2022 · 8 comments
Assignees

Comments

@WojciechMula
Copy link
Contributor

Decompress1X uses a similar approach to Decompress4X -- it first writes data to an auxiliary buffer, and the buffer is later appended to the output. In an asm we can write directly to the output (see: #577).

@WojciechMula
Copy link
Contributor Author

@klauspost there is dead code: https://github.com/klauspost/compress/blob/master/huff0/decompress.go#L310. Should it be re-enabled?

@klauspost
Copy link
Owner

klauspost commented May 23, 2022

@WojciechMula Crashers happen after merge of #596 :(

Sample crashers.zip

Could you PTAL?

@klauspost
Copy link
Owner

Test is rather simple:

func FuzzDecompress(data []byte) int {
	s, rem, err := huff0.ReadTable(data, nil)
	if err != nil {
		return 0
	}
	_, err1 := s.Decompress1X(rem)
	_, err4 := s.Decompress4X(rem, huff0.BlockSizeMax-3)
	if err1 != nil && err4 != nil {
		return 0
	}
	return 1
} 

@klauspost
Copy link
Owner

unexpected fault address 0xffffffffffffffff
fatal error: fault
[signal 0xc0000005 code=0x0 addr=0xffffffffffffffff pc=0xa463ee]

goroutine 1 [running]:
runtime.throw({0xa62546, 0x22466b4ffff})
	runtime/panic.go:1198 +0x76 fp=0xc0000d3c48 sp=0xc0000d3c18 pc=0x9c3196
runtime.sigpanic()
	runtime/signal_windows.go:260 +0x10c fp=0xc0000d3c90 sp=0xc0000d3c48 pc=0x9d46ec
github.com/klauspost/compress/huff0.(*Scratch).compress1X(...)
	e:/gopath/src/github.com/klauspost/compress/huff0/compress.go:230
github.com/klauspost/compress/huff0.(*Scratch).compress1X-fm({0xc0000d3d40, 0x2246c27001b, 0xc0003e0000})
	e:/gopath/src/github.com/klauspost/compress/huff0/compress.go:229 +0x4e fp=0xc0000d3cd8 sp=0xc0000d3c90 pc=0xa463ee
github.com/klauspost/compress/huff0.(*Decoder).Decompress1X(0xc0000d3df0, {0xc0003a0000, 0x0, 0x4000000010}, {0x2246c27001b, 0x100, 0x0})
	e:/gopath/src/github.com/klauspost/compress/huff0/decompress_amd64.go:202 +0x1fd fp=0xc0000d3db0 sp=0xc0000d3cd8 pc=0xa444dd
github.com/klauspost/compress/huff0.(*Scratch).Decompress1X(0xc000315800, {0x2246c27001b, 0x1ccc8, 0x1ccc8})
	e:/gopath/src/github.com/klauspost/compress/huff0/decompress.go:189 +0x226 fp=0xc0000d3e40 sp=0xc0000d3db0 pc=0xa3f606
github.com/klauspost/compress-fuzz/huff0.FuzzDecompress({0x2246c270000, 0xc0000d3f08, 0xb0ea20})
	e:/gopath/src/github.com/klauspost/compress-fuzz/huff0/fuzz_decompress.go:10 +0x94 fp=0xc0000d3ea0 sp=0xc0000d3e40 pc=0xa47cf4
go-fuzz-dep.Main({0xc0000d3f60, 0x2, 0x9a6b45})
	go-fuzz-dep/main.go:36 +0x15b fp=0xc0000d3f48 sp=0xc0000d3ea0 pc=0x9fdc1b
main.main()
	github.com/klauspost/compress-fuzz/huff0/go.fuzz.main/main.go:17 +0x45 fp=0xc0000d3f80 sp=0xc0000d3f48 pc=0xa47e45
runtime.main()
	runtime/proc.go:255 +0x217 fp=0xc0000d3fe0 sp=0xc0000d3f80 pc=0x9c5757
runtime.goexit()
	runtime/asm_amd64.s:1581 +0x1 fp=0xc0000d3fe8 sp=0xc0000d3fe0 pc=0x9ec8a1
exit status 2

@klauspost
Copy link
Owner

@WojciechMula Please confirm that you are looking at this, otherwise I will have to revert.

@WojciechMula
Copy link
Contributor Author

@klauspost I will take a look on Thursday. Please revert if it blocks anything, I'll back with a fix.

@klauspost
Copy link
Owner

No worries. Just don't want releases to be blocked if an urgent issue should come in.

@klauspost
Copy link
Owner

Released

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

No branches or pull requests

2 participants