Fix nil pointer dereference when sending to binary channel type alias#1715
Merged
traefiker merged 2 commits intotraefik:masterfrom Feb 9, 2026
Merged
Fix nil pointer dereference when sending to binary channel type alias#1715traefiker merged 2 commits intotraefik:masterfrom
traefiker merged 2 commits intotraefik:masterfrom
Conversation
mvertes
requested changes
Feb 7, 2026
Collaborator
mvertes
left a comment
There was a problem hiding this comment.
The fix is correct. The test case needs to be adjusted to avoid confusion with standard library test package.
Contributor
Author
|
Heya @mvertes |
Contributor
|
🚫 the mergeable state is "blocked" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When sending a value to a channel that is a type alias defined in a binary package, yaegi panics with a nil pointer dereference.
This PR was created with AI assistance (Claude) as I hit this issue in a downstream project using yaegi.
The fix and tests have been reviewed and verified for correctness and functionality by myself.
Root Cause
In the
sendfunction (interp/run.go), the code directly accessesc0.typ.valto get the channel element type:For source-defined channels (category
chanT),.valcontains the element type. But for binary channel type aliases (categoryvalueT),.valis nil - the element type is only available via reflection in.rtype.Fix
Use the existing
elem()method which correctly handles both cases:The
elem()method (intype.go) already handles this properly:This is a one-line fix that fixes binary channel type aliases by using reflection to get the element type
Test Results
TestSendToSourceDefinedChannelTestSendToSourceDefinedChannelTypeAliasTestSendToBinaryChannelTypeAliasMinimal Reproduction
mypkg/mypkg.go
symbols.go
main.go
Results
Without fix:
With fix: