Skip to content

Fix another ICU Find & Replace hang #459

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 1 commit into from
Jun 10, 2025
Merged

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Jun 10, 2025

Closes #450


// I wonder if it would make sense to use a Cow here. But probably not.
std::ptr::copy_nonoverlapping(src_cache, dst_cache, 1);
ut.a = -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this works by forcing the regeneration of all properties given the new text buffer generation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this is optional. The only use of .a is to detect whether the Cache is stale / dirty. But since we initialize it with memset(0) it's not just stale, it's also empty. So no matter what, utext_access will detect it as stale.

ut.a = tb.generation() as i64;

// ICU unfortunately expects a `UText` instance to have valid contents after construction.
utext_access(ut, 0, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this no longer true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm not sure. I'm somewhat surprised this works, but I'd like to go with that. I checked the internal ICU implementation, and it looked similar.

@lhecker lhecker merged commit a36fbe3 into main Jun 10, 2025
3 checks passed
@lhecker lhecker deleted the dev/lhecker/450-replace-hang branch June 10, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hang when search and replacing and the last character is to be replaced
2 participants