You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "slachiewicz (via GitHub)" <gi...@apache.org> on 2026/09/08 10:55:59 UTC

[PR] THRIFT-5806: Fix nil dereference panic on unset union serialization [thrift]

slachiewicz opened a new pull request, #3822:
URL: https://github.com/apache/thrift/pull/3822

   Client: go
   
   ### Problem
   When serializing a Go struct that contains a nil union field with default requiredness, `t_go_generator` generated code that invoked `CountSetFields` on the nil union receiver, causing a runtime panic (`invalid memory address or nil pointer dereference`).
   
   ### Changes
   1. Added a nil check to `CountSetFields` in `compiler/cpp/src/thrift/generate/t_go_generator.cc` returning 0 when the union receiver is `nil`.
   2. Added an `IsSet<Field>` check in `writeField` for default-requiredness pointer fields, skipping unset (nil) pointers during serialization. This matches the behavior of Python, Java, Rust, Node.js, and C# per the Thrift IDL specification (`doc/specs/idl.md:131`).
   3. Added unit regression tests in `lib/go/test/tests/union_default_value_test.go` and `lib/go/test/UnionDefaultValueTest.thrift`.
   
   Co-Authored-By: Antigravity 2.0 <no...@google.com>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] THRIFT-5806: Count zero set fields on a nil union rather than dereferencing it [thrift]

Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on PR #3822:
URL: https://github.com/apache/thrift/pull/3822#issuecomment-5654582757

   Rebased on master and added the `Co-Authored-By: Claude Opus 5` trailer to the commit; the PR description now names the tool as well. Patch content is unchanged (8517fd87f).
   
   *This comment was created with AI assistance.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] THRIFT-5806: Count zero set fields on a nil union rather than dereferencing it [thrift]

Posted by "fishy (via GitHub)" <gi...@apache.org>.
fishy merged PR #3822:
URL: https://github.com/apache/thrift/pull/3822


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] THRIFT-5806: Count zero set fields on a nil union rather than dereferencing it [thrift]

Posted by "Jens-G (via GitHub)" <gi...@apache.org>.
Jens-G commented on PR #3822:
URL: https://github.com/apache/thrift/pull/3822#issuecomment-5634152356

   ### Code review
   
   Found 1 issue:
   
   1. The commit has no AI attribution trailer, although the PR description says the change was created with AI assistance (AGENTS.md says "**Always** label AI-assisted commits and PRs. Use one or both of: `Co-Authored-By: <AI tool name and version>` / `Generated-by: <AI tool name and version>`"). The PR text names no tool or version either. The commits of #3816 and #3817 carry such a trailer.
   
   https://github.com/apache/thrift/blob/3eeb97b2f4f8326c7c8ee5a9d1f2c2cce3c40e41/AGENTS.md#L60-L74
   
   🤖 Generated with [Claude Code](https://claude.ai/code)
   
   <sub>- If this code review was useful, please react with 👍. Otherwise, react with 👎.</sub>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org