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

go-fuzz-build fails on github.com/robfig/soy #194

Closed
robfig opened this issue Nov 22, 2018 · 1 comment
Closed

go-fuzz-build fails on github.com/robfig/soy #194

robfig opened this issue Nov 22, 2018 · 1 comment

Comments

@robfig
Copy link

robfig commented Nov 22, 2018

Thanks for your amazing work on fuzz testing!

I tried to use go-fuzz to test github.com/robfig/soy, but I ended up with a Go compile error from the instrumented code. It seems like there is some scenario that's not handled correctly in go-fuzz-build.

Source code that triggers the error:

func funcIsNonnull(v []data.Value) data.Value {
	return data.Bool(!(v[0] == data.Null{} || v[0] == data.Undefined{}))
}

Instrumented code, with //line comments stripped for readability:

func funcIsNonnull(v []data.Value) data.Value {
	_go_fuzz_dep_.CoverTab[32995]++
	return data.Bool(!(func() bool {
		__gofuzz_v1 := v[0]
		__gofuzz_v2 := data.Null{}
		_go_fuzz_dep_.Sonar(__gofuzz_v1, __gofuzz_v2, 1496832)
		return __gofuzz_v1 == __gofuzz_v2
	}() == true || func() github.com/robfig/soy/data.Bool {
		_go_fuzz_dep_.CoverTab[17175]++
		return func() bool {
			__gofuzz_v1 := v[0]
			__gofuzz_v2 := data.Undefined{}
			_go_fuzz_dep_.Sonar(__gofuzz_v1, __gofuzz_v2, 1497088)
			return __gofuzz_v1 == __gofuzz_v2
		}() == true
	}()))
}

Compile error:

$ go-fuzz-build -work github.com/robfig/soy
workdir: /var/folders/hq/22l_y9yn3llfhj91mvk913xm0000gn/T/go-fuzz-build263099547
workdir: /var/folders/hq/22l_y9yn3llfhj91mvk913xm0000gn/T/go-fuzz-build281538366
failed to execute go build: exit status 2
# github.com/robfig/soy/soyhtml
.../soy/soyhtml/funcs.go:57: syntax error: unexpected ++, expecting comma or }
.../soy/soyhtml/funcs.go:57: syntax error: unexpected return, expecting )
.../soy/soyhtml/funcs.go:57: syntax error: unexpected ( after top level declaration

This line looks like the error to me, due to using the entire import path rather than just the package name:

func() github.com/robfig/soy/data.Bool {

I have pushed the code I'm working with on the "fuzz" branch:
https://github.com/robfig/soy/tree/fuzz

Let me know if I can provide anything else.
Thanks,
Rob

dvyukov added a commit to dvyukov/go-fuzz-corpus that referenced this issue Nov 23, 2018
@dvyukov
Copy link
Owner

dvyukov commented Nov 23, 2018

I can reproduce this and I added a small test case, but I am not sure when I will have time to fix this.
Another reason to remember golang/go#19109

josharian added a commit to josharian/go-fuzz that referenced this issue Dec 26, 2018
This is not a complete fix--see the comments in the code--
but it is better than what we had, and the comments now
at least draw a roadmap for any future fixes required.

Fixes dvyukov#194
bradleyjkemp pushed a commit to bradleyjkemp/simple-fuzz that referenced this issue Oct 23, 2019
This is not a complete fix--see the comments in the code--
but it is better than what we had, and the comments now
at least draw a roadmap for any future fixes required.

Fixes dvyukov#194
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

2 participants