Changeset 211360 in webkit


Ignore:
Timestamp:
Jan 30, 2017 2:14:36 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

Several web timing tests crash in GTK+ and AppleWin bots
https://bugs.webkit.org/show_bug.cgi?id=167577

Reviewed by Ryosuke Niwa.

The problem is that entry is used in both the key, to get name, and in the value with WTFMove. So, the name is
invalidated by the move. It could be fixed by simply copying the name, instead of using entry->name, but I think
that code could be simplified using HashMap::ensure and then we don't need any string copy, nor even the static
insertPerformanceEntry().

Fix crashes in several imported/w3c/web-platform-tests/user-timing/ tests.

  • page/PerformanceUserTiming.cpp:

(WebCore::UserTiming::mark):
(WebCore::UserTiming::measure):
(WebCore::insertPerformanceEntry): Deleted.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r211358 r211360  
     12017-01-30  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Several web timing tests crash in GTK+ and AppleWin bots
     4        https://bugs.webkit.org/show_bug.cgi?id=167577
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        The problem is that entry is used in both the key, to get name, and in the value with WTFMove. So, the name is
     9        invalidated by the move. It could be fixed by simply copying the name, instead of using entry->name, but I think
     10        that code could be simplified using HashMap::ensure and then we don't need any string copy, nor even the static
     11        insertPerformanceEntry().
     12
     13        Fix crashes in several imported/w3c/web-platform-tests/user-timing/ tests.
     14
     15        * page/PerformanceUserTiming.cpp:
     16        (WebCore::UserTiming::mark):
     17        (WebCore::UserTiming::measure):
     18        (WebCore::insertPerformanceEntry): Deleted.
     19
    1202017-01-30  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • trunk/Source/WebCore/page/PerformanceUserTiming.cpp

    r211332 r211360  
    8989}
    9090
    91 static void insertPerformanceEntry(PerformanceEntryMap& performanceEntryMap, Ref<PerformanceEntry>&& performanceEntry)
    92 {
    93     RefPtr<PerformanceEntry> entry = WTFMove(performanceEntry);
    94     auto it = performanceEntryMap.find(entry->name());
    95     if (it != performanceEntryMap.end())
    96         it->value.append(WTFMove(entry));
    97     else
    98         performanceEntryMap.set(entry->name(), Vector<RefPtr<PerformanceEntry>> { WTFMove(entry) });
    99 }
    100 
    10191static void clearPerformanceEntries(PerformanceEntryMap& performanceEntryMap, const String& name)
    10292{
     
    114104        return Exception { SYNTAX_ERR };
    115105
    116     insertPerformanceEntry(m_marksMap, PerformanceMark::create(markName, m_performance.now()));
     106    auto& performanceEntryList = m_marksMap.ensure(markName, [] { return Vector<RefPtr<PerformanceEntry>>(); }).iterator->value;
     107    performanceEntryList.append(PerformanceMark::create(markName, m_performance.now()));
     108
    117109    return { };
    118110}
     
    162154    }
    163155
    164     insertPerformanceEntry(m_measuresMap, PerformanceMeasure::create(measureName, startTime, endTime));
     156    auto& performanceEntryList = m_measuresMap.ensure(measureName, [] { return Vector<RefPtr<PerformanceEntry>>(); }).iterator->value;
     157    performanceEntryList.append(PerformanceMeasure::create(measureName, startTime, endTime));
     158
    165159    return { };
    166160}
Note: See TracChangeset for help on using the changeset viewer.