fix(rust): deep clone TypeMeta to prevent UB in concurrent scenarios#3511
Merged
chaokunyang merged 1 commit intoapache:mainfrom Mar 25, 2026
Merged
fix(rust): deep clone TypeMeta to prevent UB in concurrent scenarios#3511chaokunyang merged 1 commit intoapache:mainfrom
chaokunyang merged 1 commit intoapache:mainfrom
Conversation
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.
Why?
As mentioned in #3490 (comment), one cargo bench case stably fails in the current code. After some digging, I think it results from this line:
fory/rust/fory-core/src/resolver/type_resolver.rs
Line 1389 in ede9b64
The
clone()method forTypeResolvershould return a deep clone:fory/rust/fory-core/src/resolver/type_resolver.rs
Lines 1316 to 1319 in ede9b64
But the
type_meta_by_indexfield has typeVec<Option<Rc<TypeMeta>>>, callingclone()on this type directly would lead to a shadow clone indeed.The
internal_type_info_by_idfield inTypeResolveralso has a similar typeVec<Option<Rc<TypeInfo>>>but it doesn't callclone()directly.What does this PR do?
deep clone
type_meta_by_index. Now the cargo bench case can run successfully and stably.introduce bazel-setup GitHub action in C++ sanitizer job
the existing test cases in
test_multi_thread.rsare a little too weak to expose tricky concurrent issues. I wrote a new test case copying the main logic of the failed cargo bench case. Without the fix, this new test case would fail with a high chance.Related issues
No.
AI Contribution Checklist
No.
Does this PR introduce any user-facing change?
No.
Benchmark
No.