Comment 8 for bug 1761450

Revision history for this message
Jeff Young (jeyjey) wrote :

Ugh. This is scary. I found this in wx/string.h:

#if wxUSE_UNICODE_UTF8
// NB: In UTF-8 build, (non-const) iterator needs to keep reference
// to the underlying wxStringImpl, because UTF-8 is variable-length
// encoding and changing the value pointer to by an iterator (using
// its operator*) requires calling wxStringImpl::replace() if the old
// and new values differ in their encoding's length.
//
// Furthermore, the replace() call may invalid all iterators for the
// string, so we have to keep track of outstanding iterators and update
// them if replace() happens.
//
// This is implemented by maintaining linked list of iterators for every
// string and traversing it in wxUniCharRef::operator=(). Head of the
// list is stored in wxString. (FIXME-UTF8)

Note that it says "invalid[sic] all iterators" (not just const ones). So they /also/ keep const iterators in said list (I confirmed this in gdb). And it would appear that inserting and removing them from the list is not thread-safe.

With the first line of TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon() as:

   if( GetText().Length() == 0 )

I get a crash about every 3 - 5 fills.

With it as:

   if( GetText().IsEmpty() )

I haven't gotten a crash yet in 50 fills.