Skip to content

Commit bc4ba9b

Browse files
agutkincopybara-github
authored andcommitted
Fix MacOS crash which involves two static absl::flat_hash_set globals.
Details: ```shell Assertion failed: (ctrl != nullptr), function iterator, file external/com_google_absl/absl/container/internal/raw_hash_set.h, line 749. Process 70835 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert frame #4: 0x000000010000ae22 utf8_delimiters_test`absl::container_internal::raw_hash_set<absl::container_internal::FlatHashSetPolicy<char32_t>, absl::hash_internal::Hash<char32_t>, std::__1::equal_to<char32_t>, std::__1::allocator<char32_t> >::iterator::iterator(signed char*, char32_t*) + 98 utf8_delimiters_test`absl::container_internal::raw_hash_set<absl::container_internal::FlatHashSetPolicy<char32_t>, absl::hash_internal::Hash<char32_t>, std::__1::equal_to<char32_t>, std::__1::allocator<char32_t> >::iterator::iterator: -> 0x10000ae22 <+98>: jmp 0x10000ae27 ; <+103> 0x10000ae27 <+103>: addq $0x20, %rsp 0x10000ae2b <+107>: popq %rbp 0x10000ae2c <+108>: retq Target 0: (utf8_delimiters_test) stopped. (lldb) up ``` PiperOrigin-RevId: 382336985
1 parent cf78fbb commit bc4ba9b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

nisaba/port/unicode_properties.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace nisaba {
2121
namespace utf8 {
2222
namespace {
2323

24-
const absl::flat_hash_set<char32_t> kBreakingWhitespace = {
24+
constexpr char32_t kBreakingWhitespace[] = {
2525
U'\u0009', // character tabulation
2626
U'\u000A', // line feed
2727
U'\u000B', // line tabulation
@@ -49,7 +49,7 @@ const absl::flat_hash_set<char32_t> kBreakingWhitespace = {
4949
U'\u3000', // ideographic space
5050
};
5151

52-
const absl::flat_hash_set<char32_t> kNonBreakingWhitespace = {
52+
constexpr char32_t kNonBreakingWhitespace[] = {
5353
U'\u180E', // mongolian vowel separator
5454
U'\u200B', // zero width space
5555
U'\u200C', // zero width non-joiner
@@ -61,17 +61,20 @@ const absl::flat_hash_set<char32_t> kNonBreakingWhitespace = {
6161
} // namespace
6262

6363
absl::flat_hash_set<char32_t> GetBreakingWhitespaceChars() {
64-
return kBreakingWhitespace;
64+
return absl::flat_hash_set<char32_t>(std::begin(kBreakingWhitespace),
65+
std::end(kBreakingWhitespace));
6566
}
6667

6768
absl::flat_hash_set<char32_t> GetNonBreakingWhitespaceChars() {
68-
return kNonBreakingWhitespace;
69+
return absl::flat_hash_set<char32_t>(std::begin(kNonBreakingWhitespace),
70+
std::end(kNonBreakingWhitespace));
6971
}
7072

7173
absl::flat_hash_set<char32_t> GetAllWhitespaceChars() {
7274
absl::flat_hash_set<char32_t> all_chars;
73-
std::set_union(kBreakingWhitespace.begin(), kBreakingWhitespace.end(),
74-
kNonBreakingWhitespace.begin(), kNonBreakingWhitespace.end(),
75+
std::set_union(std::begin(kBreakingWhitespace), std::end(kBreakingWhitespace),
76+
std::begin(kNonBreakingWhitespace),
77+
std::end(kNonBreakingWhitespace),
7578
std::inserter(all_chars, all_chars.begin()));
7679
return all_chars;
7780
}

0 commit comments

Comments
 (0)