Bug 101337 - [Qt] NonSharedCharacterBreakIterator leads to CRASH() in configurations that do not have COMPARE_AND_SWAP enabled
Summary: [Qt] NonSharedCharacterBreakIterator leads to CRASH() in configurations that ...
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P3 Normal
Assignee: Nobody
Depends on:
Reported: 2012-11-06 05:09 PST by Cedric Hombourger
Modified: 2013-10-02 21:36 PDT (History)
2 users (show)

See Also:

Patch to fix TextBreakIteratorQt.cpp (2.06 KB, patch)
2013-06-20 06:05 PDT, Istvan Sarkany
sarkany.istvan: commit-queue?
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cedric Hombourger 2012-11-06 05:09:43 PST
While trying to bring-up the QtWebkit-2.3 on an embedded system running an ARM 11MPCore, found ~NonSharedCharacterBreakIterator() to lead to a CRASH()

(gdb) bt
#0  0x2cda3318 in weakCompareAndSwap (this=0x7ebd8c3c, __in_chrg=<value optimized out>)
    at /home/chombourger/bp-mvl-project/tmp/work/armv6-mv-linux/qtwebkit-2.3.0-r4/chombourger-qtwebkit-23/Source/WTF/wtf/Atomics.h:200
#1  WebCore::NonSharedCharacterBreakIterator::~NonSharedCharacterBreakIterator (this=0x7ebd8c3c, 
    __in_chrg=<value optimized out>)
    at /home/chombourger/bp-mvl-project/tmp/work/armv6-mv-linux/qtwebkit-2.3.0-r4/chombourger-qtwebkit-23/Source/WebCore/platform/text/qt/TextBreakIteratorQt.cpp:87

Found this to be caused by TextBreakIteratorQt.cpp making use of weakCompareAndSwap even though COMPARE_AND_SWAP is not enabled in my configuration.

Looks like the same issue existed in the ICU implementation and was worked-around by adding a static mutex to protect the single entry NonSharedCharacterBreakIterator cache

Configuration details:

git: git://gitorious.org/+qtwebkit-developers/webkit/qtwebkit-23.git
rev: abd77b3f85375632aa313934e8eb9ae89f2bbf2e

cat /proc/cpuinfo 
Processor       : ARMv6-compatible processor rev 4 (v6l)
processor       : 0
BogoMIPS        : 398.95

processor       : 1
BogoMIPS        : 398.95

Features        : swp half thumb fastmult vfp edsp java 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb02
CPU revision    : 4
Comment 1 Cedric Hombourger 2012-11-06 05:23:28 PST
Adding compareAndSwapNonSharedCharacterBreakIterator() to Source/WebCore/platform/text/qt/TextBreakIteratorQt.cpp

+    static inline bool compareAndSwapNonSharedCharacterBreakIterator(TextBreakIterator* expected, TextBreakIterator* newV
+    {
+        return weakCompareAndSwap(reinterpret_cast<void**>(&nonSharedCharacterBreakIterator), expected, newValue);
+        DEFINE_STATIC_LOCAL(QMutex, nonSharedCharacterBreakIteratorMutex, ());
+        QMutexLocker locker(&nonSharedCharacterBreakIteratorMutex);
+        if (nonSharedCharacterBreakIterator != expected)
+            return false;
+        nonSharedCharacterBreakIterator = newValue;
+        return true;
+    }

and use from:

NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator(const UChar* buffer, int length)
Comment 2 Istvan Sarkany 2013-06-20 06:05:14 PDT
Created attachment 205080 [details]
Patch to fix TextBreakIteratorQt.cpp

I've also encountered this problem when building and running QtWebkit 2.3 on MiPS.
Since the TextBreakIteratorICU.cpp already has a similar patch, I think this should also be patched. I've attached the proposed patch based on Cedric's comment.
Comment 3 Rex Dieter 2013-09-12 10:12:53 PDT
I think we're seeing this too downstream on fedora20/arm :


Will test out the proposed patch here, and give feedback.
Comment 4 Allan Sandfeld Jensen 2013-09-13 08:52:07 PDT
The patch has been applied to qtwebkit-2.3-staging and will be part of 2.3.4 when released.
Comment 5 Anders Carlsson 2013-10-02 21:36:28 PDT
Comment on attachment 205080 [details]
Patch to fix TextBreakIteratorQt.cpp

Qt has been removed, clearing review flags.