gui: patch icu - #11232
Conversation
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
There was a problem hiding this comment.
Code Review
This pull request introduces a patch to null-check Bazel runfiles in ICU to prevent segmentation faults when binaries are copied out of the bazel-bin directory. However, the patch introduces a critical Use-After-Free (UAF) bug because path is assigned to the c_str() of a local std::string (dat_path) which is destroyed when the function returns. To resolve this, the lifetime of dat_path should be extended by making it static.
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
|
Pushed a follow-up commit ( Once the I checked Qt's own if (d->collator) {
return ucol_strcoll(d->collator, ...);
}
return QtPrivate::compareStrings(s1, s2, d->caseSensitivity);So this is cosmetic noise, not a functional regression — file listings and sortable tables still sort correctly, just without locale-aware collation (irrelevant for ASCII filenames). Suppressed it in the existing Qt-message interceptor ( |
Summary
Fix done using Claude.
QFileDialog's built-in file listing (QFileSystemModel) sorts entries with a locale-aware compare, which constructs aQCollatorand loads ICU locale data. The Bazel Central Registry'sicumodule patchesu_getDataDirectory()to locate that data viarules_cc::cc::runfiles::Runfiles::Rlocation(), butRunfiles::Create()returnsnullptrwhenever no runfiles tree is reachable, and the overlay dereferences it unconditionally. A binary produced bybazel/install.shhas its.runfilesdirectory stripped after unpacking, so the very first locale-aware compare anywhere in the process — e.g.QFileDialog::getOpenFileNamepopulating its file list — segfaults.This is the same defect class fixed in #11203 for
HelpWidget::sortItems(); that PR's own "Scope" section flagged the file-dialog path as still open: "a file dialog'sQFileSystemModel... would still reach the same unchecked pointer."Rather than patch each call site that happens to trigger a collated sort, this adds a
single_version_overrideon theicumodule (pulled in transitively viaqt-bazel) that null-checksRunfiles::Create()'s result before calling->Rlocation()on it, falling through to ICU's existing""default instead of crashing. This closes the bug for every locale-aware sort in the GUI (file dialogs, sortable timing tables, etc.), not justHelpWidget.Every
icuversion currently in the BCR carries the same unchecked dereference (76.1.bcr.4,78.2.bcr.2, ...), so bumping the version is not a workaround; only patchingputil.cppfixes it. The real fix belongs upstream in the BCR'sicumodule — this override should be dropped once that lands.Type of Change
Impact
No behavior change for anyone whose binary still has a reachable runfiles tree (e.g. running via
bazel run/bazel-bindirectly) —Runfiles::Rlocation()still resolves andpathis still set exactly as before. For an installed binary (no runfiles tree), ICU's data directory now silently falls back to""instead of segfaulting; ICU already handles that case gracefully elsewhere indataDirectoryInitFn(). Fixes the crash reported in #11217 (opening the "Open DB" file dialog) and the equivalent one in OpenROAD-flow-scripts#4454 (DRC Viewer's "Load" file chooser).Verification
./etc/Build.sh).Verified directly at the Bazel module level rather than a full
./etc/Build.shrun:bazelisk mod graphresolvesicu@76.1.bcr.3with the override applied.bazelisk fetchon the real@icuexternal repo, then inspected the materialized source on disk — the null-check is present after the BCR's own overlay patches are applied on top of it.bazelisk build @@icu+//icu4c/source/common:platform(the target compiling the patchedputil.cpp) builds cleanly.qt_bazel_prebuilts's ownMODULE.bazel(a non-root module here) causes Bazel to silently ignore it and refetch the unpatched, vulnerable source — confirming the override must live in whichever module is root (openroadhere, andorfsfor the ORFS-side build), not inqt-bazelitself.No regression test added: this is a Bazel dependency-patch fix with no C++ code path in this repo to exercise, and there's no existing harness for asserting installed-binary runfiles-absent behavior (same reasoning as #11203).
Related Issues
Fixes #11217
Related: OpenROAD-flow-scripts#4454