chaokunyang opened a new pull request, #2991:
URL: https://github.com/apache/fory/pull/2991
## Summary
- Go: Fixed struct value reference tracking - struct values are value types
that should not participate in reference tracking (was incorrectly using JSON
marshaling for content-based deduplication)
- Python: Fixed `reference()` to handle empty `read_ref_ids` when
`NotNullValueFlag` is received (prevents segfault during cross-language
deserialization)
## What was the problem?
Go was incorrectly treating struct **values** (not pointers) as if they were
reference types:
1. It used `json.Marshal()` to create a content-based cache key for struct
values
2. This was semantically wrong - Go struct values are copied, not shared by
reference
3. This was also slow due to JSON marshaling overhead
When Go was changed to correctly write `NotNullValueFlag` (-1) for struct
values instead of `RefValueFlag` (0), Python's deserializer crashed because:
1. Python's `reference()` assumed a ref ID was always preserved when ref
tracking is enabled
2. With `NotNullValueFlag`, no ref ID is preserved in `read_ref_ids`
3. Calling `read_ref_ids.pop()` on an empty list caused a segfault in Cython
## Changes
1. **Go (reference.go)**:
- Struct values now write `NotNullValueFlag` (-1) correctly
- Removed `basicValueCache` and `json` import
2. **Python (resolver.py, serialization.pyx)**:
- Added check for empty `read_ref_ids` before popping in `reference()`
## Test plan
- [x] All Go tests pass including cross-language tests
- [x] All Python struct tests pass
- [x] Tested with both Cython and pure Python modes
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]