Skip to content
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

ICU-21383 Fix memory problem in FormattedStringBuilder #1450

Merged
merged 1 commit into from
Nov 11, 2020

Conversation

sffc
Copy link
Member

@sffc sffc commented Nov 10, 2020

The fix to the reported issue, a list with more than 8 elements, is the addition of an argument to the .resize() call in appendSpanInfo. The other fix, at the bottom of nextPositionImpl, came up in Valgrind during testing and is triggered when calling .nextPosition() repeatedly after it has returned false.

Checklist

@sffc sffc requested a review from FrankYFTang November 10, 2020 06:47
@sffc sffc requested a review from hugovdm November 10, 2020 06:49
@sffc
Copy link
Member Author

sffc commented Nov 10, 2020

FYI @hugovdm: a bug one can make when using MaybeStackArray: don't forget to pass the optional length parameter to the resize function!

Copy link
Contributor

@hugovdm hugovdm left a comment

Choose a reason for hiding this comment

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

Looks good to me, except that the C++ and Java unit tests have falling out of sync?

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/ListFormatterTest.java is now changed in the branch

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@sffc
Copy link
Member Author

sffc commented Nov 10, 2020

OK, I added the corresponding Java tests via amend. This was an ICU4C-specific bug, but it doesn't hurt to add the ICU4J tests, since it helps to keep the two unit test suites in sync, as you pointed out.

Copy link
Contributor

@FrankYFTang FrankYFTang left a comment

Choose a reason for hiding this comment

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

Please change the U_ASSERT condition to >

hugovdm
hugovdm previously approved these changes Nov 10, 2020
Copy link
Contributor

@hugovdm hugovdm left a comment

Choose a reason for hiding this comment

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

Looks good to me. (The assert also made sense to me.)

The MSYS2 failure looks unrelated to this PR:

configure: error: in `/d/a/1/s/icu4c/source':
configure: error: no acceptable C compiler found in $PATH

FrankYFTang
FrankYFTang previously approved these changes Nov 10, 2020
macchiati
macchiati previously approved these changes Nov 10, 2020
@jefgen
Copy link
Member

jefgen commented Nov 10, 2020

The MSYS2 failure looks unrelated to this PR:

configure: error: in `/d/a/1/s/icu4c/source':
configure: error: no acceptable C compiler found in $PATH

Hmm.. I'll try to re-run the build again...

markusicu
markusicu previously approved these changes Nov 10, 2020
Copy link
Member

@markusicu markusicu left a comment

Choose a reason for hiding this comment

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

lgtm

@sffc sffc dismissed stale reviews from markusicu, macchiati, FrankYFTang, and hugovdm via 473bb11 November 10, 2020 21:49
@sffc
Copy link
Member Author

sffc commented Nov 10, 2020

Thanks for all the reviews. However, I caught two mistakes which I fixed in another amendment:

  1. I need to change this behavior in prependSpanInfo too, not just appendSpanInfo
  2. .resize() returns nullptr if it fails to allocate memory, but I'm not handling that case

Please re-review.

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • icu4c/source/i18n/formattedval_impl.h is now changed in the branch
  • icu4c/source/i18n/formattedval_sbimpl.cpp is different
  • icu4c/source/i18n/listformatter.cpp is now changed in the branch

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@sffc
Copy link
Member Author

sffc commented Nov 10, 2020

Note: The Jira-GitHub bot seems to have been down for a time. I manually re-sent the webhook request, which is why it was delayed.

@sffc sffc merged commit e7f6673 into unicode-org:maint/maint-68 Nov 11, 2020
@sffc sffc deleted the ICU-21383-sbimpl branch November 11, 2020 15:40
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.

6 participants