-
Notifications
You must be signed in to change notification settings - Fork 849
string.c: record the source overlap before str_modify_cat() runs #7043
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: mruby/mruby
Length of output: 20879
🏁 Script executed:
Repository: mruby/mruby
Length of output: 240
🏁 Script executed:
Repository: mruby/mruby
Length of output: 50367
Use integer address math before modifying
str.mrb_str_cat()accepts pointers from any object. Insrc/string.c:3144-3145, comparing/subtractingptragainstRSTR_PTR(s)beforemrb_str_modify()can compare unrelated pointers. Useuintptr_tarithmetic for the containment check beforemrb_str_modify()moves the string buffer.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison this points at is not introduced here. Master carries the same expression, and this PR moves it above
str_modify_cat()without changing its form, so the two pointers are as related or unrelated as they were before. The position is what this PR is about.The formal point stands on its own merits: relational comparison and subtraction between pointers into different objects is undefined by C11 6.5.8p5 and 6.5.6p9, and a containment check has no portable spelling other than
uintptr_t. mruby already spells one that way inis_pool_memory()inmrbgems/mruby-bigint/core/bigint.c. If that is worth applying tomrb_str_cat(), it should come as its own change against master rather than ride along with an ordering fix.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@takumin, agreed. This finding is outside the scope of#7043.The PR preserves the existing pointer expression and changes only when
mrb_str_cat()records overlap. I will not treat theuintptr_tportability concern as a required change for this PR.If you want, I can open a separate issue for a master-targeted update to the containment check in
mrb_str_cat().(ᵔᴥᵔ)
You are interacting with an AI system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issue needed. That change is already up as #7051 against master, which converts both operands of the containment check to
uintptr_t. It also records that whichever of the two lands first, the other gets rebased onto it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@takumin, understood.#7051already contains theuintptr_tcontainment-check fix and the rebasing behavior for either allocation order.No follow-up issue is needed.
#7043remains scoped to recording the overlap offset beforestr_modify_cat().You are interacting with an AI system.