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

transport/http: depends on equality of pointer to zero-sized objects #568

Open
randall77 opened this issue Feb 12, 2025 · 0 comments
Open

Comments

@randall77
Copy link

In transport/http/identity_test.go, TestIdentity compares the result from resolver.GetIdentity with &auth.AnonymousIdentity{}. That test is fragile, as the behavior of comparing pointers to zero-sized objects (which auth.AnonymousIdentity is) is not guaranteed (https://go.dev/ref/spec#Comparison_operators, bullet point 6).

This test, and presumably other clients of auth.IdentityResolvers, should use a type assertion instead of interface equality.

Replace

if expected != actual {

with

if _, ok := actual.(*auth.AnonymousIdentity); !ok {

(Or a sentinel value should be defined in auth instead of a sentinel type.)

We believe this test will fail in the upcoming go1.25 (~August 2025) because of optimizations that change the behavior of equality on pointer-to-zero-sized allocations.

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

1 participant