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

export struct members for signature benchmark #390

Merged
merged 1 commit into from
Sep 21, 2024

Conversation

mischief
Copy link
Contributor

i assume unexported fields are skipped on purpose, but computing the signature of a struct with no exported fields in a benchmark seems sort of pointless and also panics. export the fields so that we actually compute their signature, and prevent panic'ing on an empty struct.

fixes:

panic: dbus: invalid type struct { b uint8; i int32; t uint64; s string }

goroutine 12 [running]:
github.com/godbus/dbus/v5.getSignature({0x74c3c0, 0x6bbf60}, 0xc0000aaed8)
	/home/mischief/src/go-dbus/sig.go:106 +0xa25
github.com/godbus/dbus/v5.getSignature({0x74c3c0, 0x6822e0}, 0xc0000aaed8)
	/home/mischief/src/go-dbus/sig.go:110 +0x60c
github.com/godbus/dbus/v5.SignatureOf({0x8fcb40?, 0xc000193f40?, 0x518452?})
	/home/mischief/src/go-dbus/sig.go:37 +0x50
github.com/godbus/dbus/v5.BenchmarkGetSignatureLong(0xc000148788)
	/home/mischief/src/go-dbus/sig_test.go:68 +0x36
testing.(*B).runN(0xc000148788, 0x1)
	/usr/lib/go/src/testing/benchmark.go:193 +0xf8
testing.(*B).run1.func1()
	/usr/lib/go/src/testing/benchmark.go:215 +0x4e
created by testing.(*B).run1 in goroutine 1
	/usr/lib/go/src/testing/benchmark.go:208 +0x90

when executing:

go test -v -bench BenchmarkGetSignatureLong -run ^$ .

i assume unexported fields are skipped on purpose, but computing the signature
of a struct with no exported fields in a benchmark seems sort of pointless and
also panics. export the fields so that we actually compute their signature, and
prevent panic'ing on an empty struct.

fixes:

	panic: dbus: invalid type struct { b uint8; i int32; t uint64; s string }

	goroutine 12 [running]:
	github.com/godbus/dbus/v5.getSignature({0x74c3c0, 0x6bbf60}, 0xc0000aaed8)
		/home/mischief/src/go-dbus/sig.go:106 +0xa25
	github.com/godbus/dbus/v5.getSignature({0x74c3c0, 0x6822e0}, 0xc0000aaed8)
		/home/mischief/src/go-dbus/sig.go:110 +0x60c
	github.com/godbus/dbus/v5.SignatureOf({0x8fcb40?, 0xc000193f40?, 0x518452?})
		/home/mischief/src/go-dbus/sig.go:37 +0x50
	github.com/godbus/dbus/v5.BenchmarkGetSignatureLong(0xc000148788)
		/home/mischief/src/go-dbus/sig_test.go:68 +0x36
	testing.(*B).runN(0xc000148788, 0x1)
		/usr/lib/go/src/testing/benchmark.go:193 +0xf8
	testing.(*B).run1.func1()
		/usr/lib/go/src/testing/benchmark.go:215 +0x4e
	created by testing.(*B).run1 in goroutine 1
		/usr/lib/go/src/testing/benchmark.go:208 +0x90

when executing:

	go test -v -bench BenchmarkGetSignatureLong -run ^$ .
Copy link
Member

@guelfey guelfey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@guelfey guelfey merged commit a817f3c into godbus:master Sep 21, 2024
7 checks passed
@mischief mischief deleted the signature-panic branch September 21, 2024 18:16
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

Successfully merging this pull request may close these issues.

2 participants