<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>6332</bug_id>
          
          <creation_ts>2014-05-14 21:21:26 +0000</creation_ts>
          <short_desc>bbclass handlers that handle MetadataEvent&apos;s clobber that event&apos;s &apos;data&apos; member</short_desc>
          <delta_ts>2014-10-28 10:47:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>1.6</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>1.7</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Dave Lerner">dave.lerner</reporter>
          <assigned_to name="Alexandru Damian">alexandru.damian</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>43345</commentid>
    <comment_count>0</comment_count>
      <attachid>1958</attachid>
    <who name="Dave Lerner">dave.lerner</who>
    <bug_when>2014-05-14 21:21:26 +0000</bug_when>
    <thetext>Created attachment 1958
a bbclass that is dispatched with MetadataEvent or all events

As tested in daisy release.

If the function bb.event.execute_handler() is called to run a registered
event handler, and if the event is a MetadataEvent, then the event member
variable &apos;data&apos;, is destroyed by execute_handler() which causes failures
for other handlers registered for that event, such as the toaster
event handlers.

This happens when either
- a bbclass invokes &apos;addhandler&apos; without setting an event mask, and
consequently gets all events, or
- a bbclass adds the handler and sets the handler&apos;s event mask to MetadataEvent.

To reproduce the case where a handler receiving all events clobbers
the MetadataEvent.data member variable:
1) copy the attached file bug_event.bbclass into poky/meta/classes
2) run the init script
    source oe-init-build-env
3) append to conf/local.conf
    INHERIT += &quot;bug_event&quot;
4) start toaster which listens for metadata events
    source toaster start
5) generate some events
    bitbake quilt-native
    ...
    NOTE: bug_event: data was found in vars as dispatched by execute_handler
    ...
The event handler reports that all MetadataEvents have the &apos;data&apos; member
variable, as shown by the above highlighted &quot;NOTE: bug_event&quot;, only the &quot;&apos;data&apos; in vars(e)&quot; clause executes in the code below:
    python bug_event() {
        if isinstance(e, bb.event.MetadataEvent):
            if &apos;data&apos; in vars(e):
                bb.note(&quot;bug_event: data was found in vars as dispatched by ...
            else:
                bb.note(&quot;bug_event: data was NOT found in vars as dispatched by.
    }

6) While the bug_event.bbclass reports that MetadataEvent.data existed,
the toaster event handlers reports that the metadata events have lost
the &apos;data&apos; member variable:
    grep assert toaster_ui.log
    assert &apos;data&apos; in vars(event)
    ...

To reproduce the case where a handler receiving metadata events first
clobbers the &apos;data&apos; field for subsequent handlers
1) edit the poky/meta/classes/bug_event.bbclass to uncomment
the eventmask line
    - #bug_events[eventmask] = &quot;bb.event.MetadataEvent&quot;
    + bug_events[eventmask] = &quot;bb.event.MetadataEvent&quot;
2) reset toaster and toaster logs
    source toaster stop ; rm toaster* ; source toaster start
3) generate some events
    bitbake quilt-native
    ...
    NOTE: bug_event: data was found in vars as dispatched by execute_handler
    ...
4) the toaster logs still assert MetadataEvent.data is missing:
    grep assert toaster_ui.log
    assert &apos;data&apos; in vars(event)
    ...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43371</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-05-15 15:04:05 +0000</bug_when>
    <thetext>The data member is only available in certain events. If you look at the server event code, this is added for some classes of events, and not added for others.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43379</commentid>
    <comment_count>2</comment_count>
    <who name="Dave Lerner">dave.lerner</who>
    <bug_when>2014-05-15 15:49:35 +0000</bug_when>
    <thetext>I don&apos;t understand your comment.  Should MetadataEvent constructor not setup a &apos;data&apos; member variable that is potentially destroyed by execute_handler if a bbclass registers for all events?

The way execute_handler is written it assumes that _NO_ event has a &apos;data&apos; member.

1) If a handler does not set an event mask, then the MetadataEvent will be dispatched to that handler via execute_handler
2) During the dispatch in execute_handler the MetadataEvent.data member is
  a) first overwritten,
  b) then deleted
3) When the MetadataEvent is then sent to the UI handler, the MetadataEvent.data field expected by the toaster handlers has been destroyed and toaster throws an assert.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43506</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-05-22 15:40:08 +0000</bug_when>
    <thetext>Basically, we *cannot* send the data store over serialization. This means that while we can have it available for class events, it cannot be passed over to the UI and therefore it will not be present in the events the UI sees.

We don&apos;t want this to happen either, the data store is *huge* and it would be bad to try and serialize and transfer it repeatedly through something like xmlrpc.

So any data store present in events gets killed off by bb.event.execute_handler(), this is by design and isn&apos;t something we can easily change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43507</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-05-22 15:45:10 +0000</bug_when>
    <thetext>Sorry, Paul clarified this. The &quot;data&quot; namespace in events is reserved for the datastore. The MetadataEvent is going to need to use a different name. Assigning to Alex to resolve.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44564</commentid>
    <comment_count>5</comment_count>
    <who name="Alexandru Damian">alexandru.damian</who>
    <bug_when>2014-07-18 13:12:20 +0000</bug_when>
    <thetext>Patch sent to mailing lists.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46615</commentid>
    <comment_count>6</comment_count>
    <who name="Alexandru Damian">alexandru.damian</who>
    <bug_when>2014-10-28 10:47:09 +0000</bug_when>
    <thetext>Merged and Fixed.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>1958</attachid>
            <date>2014-05-14 21:21:26 +0000</date>
            <delta_ts>2014-05-14 21:21:26 +0000</delta_ts>
            <desc>a bbclass that is dispatched with MetadataEvent or all events</desc>
            <filename>bug_event.bbclass</filename>
            <type>application/octet-stream</type>
            <size>644</size>
            <attacher name="Dave Lerner">dave.lerner</attacher>
            
              <data encoding="base64">CiMgUmVwcm9kdWNlciBmb3IgdGhlIGJ1ZyBpbiBiaXRiYWtlL2xpYi9iYi9ldmVudC5weSB0aGF0
IGRlbW9uc3RyYXRlcwojICh3aXRoIHRoZSBhc3NlcnRpb24gaGVscCBvZiBiaXRiYWtlL2xpYi9i
Yi91aS9idWlsZGluZm9oZWxwZXIucHkpCiMgdGhhdCBhIGNsYXNzIGhhbmRsZXIgdGhhdCBoYW5k
bGVzIGFsbCBldmVudHMgd2lsbCBkZXN0cm95CiMgTWV0YWRhdGFFdmVudC5kYXRhIGR1cmluZyB0
aGUgZGlzcGF0Y2ggaW4gYmIuZXZlbnQuZXhlY3V0ZV9oYW5kbGVyKCkuCgpweXRob24gYnVnX2V2
ZW50KCkgewogICAgaWYgaXNpbnN0YW5jZShlLCBiYi5ldmVudC5NZXRhZGF0YUV2ZW50KToKICAg
ICAgICBpZiAnZGF0YScgaW4gdmFycyhlKToKICAgICAgICAgICAgYmIubm90ZSgiYnVnX2V2ZW50
OiBkYXRhIHdhcyBmb3VuZCBpbiB2YXJzIGFzIGRpc3BhdGNoZWQgYnkgZXhlY3V0ZV9oYW5kbGVy
IikKICAgICAgICBlbHNlOgogICAgICAgICAgICBiYi5ub3RlKCJidWdfZXZlbnQ6IGRhdGEgd2Fz
IE5PVCBmb3VuZCBpbiB2YXJzIGFzIGRpc3BhdGNoZWQgYnkgZXhlY3V0ZV9oYW5kbGVyIikKfQog
ICAgCmFkZGhhbmRsZXIgYnVnX2V2ZW50CiNidWdfZXZlbnRbZXZlbnRtYXNrXSA9ICJiYi5ldmVu
dC5NZXRhZGF0YUV2ZW50Igo=
</data>

          </attachment>
      

    </bug>

</bugzilla>