Title: [235482] trunk/Tools
Revision
235482
Author
[email protected]
Date
2018-08-29 15:20:15 -0700 (Wed, 29 Aug 2018)

Log Message

lldb-webkit: KeyError thrown for uninitialized OptionSet
https://bugs.webkit.org/show_bug.cgi?id=189070

Reviewed by Simon Fraser.

Do not compute what enumerators are in an uninitialized OptionSet. A local OptionSet variable
is only considered initialized when execution passes over its assignment regardless of whether
the variable is in scope.

The LLDB Python API does not provide a way to determine whether an variable is initialized.
So, we use a simple heuristic: when the value of the OptionSet is greater than the value
of the bitmask with all enumerators set then we consider the OptionSet to be garbage (i.e.
uninitialized memory). When the variable is finally initialized LLDB will notify us to update
our state.

* lldb/lldb_webkit.py:
(WTFOptionSetProvider.update):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (235481 => 235482)


--- trunk/Tools/ChangeLog	2018-08-29 22:01:21 UTC (rev 235481)
+++ trunk/Tools/ChangeLog	2018-08-29 22:20:15 UTC (rev 235482)
@@ -1,3 +1,23 @@
+2018-08-29  Daniel Bates  <[email protected]>
+
+        lldb-webkit: KeyError thrown for uninitialized OptionSet
+        https://bugs.webkit.org/show_bug.cgi?id=189070
+
+        Reviewed by Simon Fraser.
+
+        Do not compute what enumerators are in an uninitialized OptionSet. A local OptionSet variable
+        is only considered initialized when execution passes over its assignment regardless of whether
+        the variable is in scope.
+
+        The LLDB Python API does not provide a way to determine whether an variable is initialized.
+        So, we use a simple heuristic: when the value of the OptionSet is greater than the value
+        of the bitmask with all enumerators set then we consider the OptionSet to be garbage (i.e.
+        uninitialized memory). When the variable is finally initialized LLDB will notify us to update
+        our state.
+
+        * lldb/lldb_webkit.py:
+        (WTFOptionSetProvider.update):
+
 2018-08-29  Chris Dumez  <[email protected]>
 
         [PSON] We should only process-swap when eTLD+1 changes on navigation

Modified: trunk/Tools/lldb/lldb_webkit.py (235481 => 235482)


--- trunk/Tools/lldb/lldb_webkit.py	2018-08-29 22:01:21 UTC (rev 235481)
+++ trunk/Tools/lldb/lldb_webkit.py	2018-08-29 22:20:15 UTC (rev 235482)
@@ -612,7 +612,9 @@
         return None
 
     def update(self):
-        self.storage = self.valobj.GetChildMemberWithName('m_storage')
+        self.storage = self.valobj.GetChildMemberWithName('m_storage')  # May be uninitialized memory
+        self._elements = []
+        self.size = 0
 
         template_argument_sbType = self.valobj.GetType().GetTemplateArgumentType(0)
         enumerator_value_to_name_map = {sbTypeEnumMember.GetValueAsUnsigned(): sbTypeEnumMember.GetName() for sbTypeEnumMember in template_argument_sbType.get_enum_members_array()}
@@ -619,9 +621,14 @@
         if not enumerator_value_to_name_map:
             return
 
+        bitmask_with_all_options_set = sum(enumerator_value_to_name_map)
+        bitmask = self.storage.GetValueAsUnsigned(0)
+        if bitmask > bitmask_with_all_options_set:
+            return  # self.valobj is uninitialized memory
+
+        # self.valobj looks like it contains a valid value.
         # Iterate from least significant bit to most significant bit.
         elements = []
-        bitmask = self.storage.GetValueAsUnsigned(0)
         while bitmask > 0:
             current = bitmask & -bitmask  # Isolate the rightmost set bit.
             elements.append((enumerator_value_to_name_map[current], current))  # e.g. ('Spelling', 4)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to