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

Undefined behavior triggered in C code #113

Closed
kmicklas opened this issue Mar 10, 2022 · 2 comments
Closed

Undefined behavior triggered in C code #113

kmicklas opened this issue Mar 10, 2022 · 2 comments

Comments

@kmicklas
Copy link

What version of Go are you using (go version)?

go version go1.17.8 linux/amd64

What operating system and processor architecture are you using (go env)?

Ubuntu 20.04

What did you do?

I don't currently have a simple reproduction example for this, but it seems like all of our tests using this library will crash if you enable UBSAN (-fsanitize=undefined) with zig cc / clang as the C toolchain.

What did you expect to see?

Code using this library executes successfully with UBSAN.

What did you see instead?

Here is an example snippet which may narrow down the bug:

runtime.cgocall(0x27d7850, 0xc00086b700)
	GOROOT/src/runtime/cgocall.go:156 +0x5c fp=0xc00086b6d8 sp=0xc00086b6a0 pc=0x16abbfc
github.com/DataDog/zstd._Cfunc_ZSTD_compressBegin(0x7f00fc000c50, 0x5)
	_cgo_gotypes.go:178 +0x4d fp=0xc00086b700 sp=0xc00086b6d8 pc=0x278b36d
github.com/DataDog/zstd.NewWriterLevelDict.func1(0x7f00fc000c50, 0x5)
	__main__/external/com_github_datadog_zstd/zstd_stream.go:68 +0x4f fp=0xc00086b730 sp=0xc00086b700 pc=0x278be6f
github.com/DataDog/zstd.NewWriterLevelDict({0x958ae0, 0xc000994330}, 0x5, {0x0, 0x0, 0x0})
	__main__/external/com_github_datadog_zstd/zstd_stream.go:68 +0xc5 fp=0xc00086b788 sp=0xc00086b730 pc=0x278bb65
github.com/DataDog/zstd.NewWriter(...)
	__main__/external/com_github_datadog_zstd/zstd_stream.go:46

I think this should be pretty easy to reproduce if you enable UBSAN, but if there is any trouble I can try to provide more debugging info.

@bsergean
Copy link
Contributor

Do the UBSAN problem also exists in the zstd library, or are they unique to the datadog / zstd binding ?

@Viq111
Copy link
Collaborator

Viq111 commented Mar 17, 2023

I'm going to close this one it's unclear whether the report lies in facebook/zstd or DataDog/zstd, feel free to reopen/create a new issue if this relates to the Go zstd wrapper

@Viq111 Viq111 closed this as completed Mar 17, 2023
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

3 participants