<?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>7263</bug_id>
          
          <creation_ts>2015-01-29 11:12:04 +0000</creation_ts>
          <short_desc>Error Reporting Tool can&apos;t cope with binary data in the logs</short_desc>
          <delta_ts>2015-02-10 15:24:12 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>6</classification_id>
          <classification>Yocto Project Subprojects</classification>
          <product>Error Reporting tool</product>
          <component>Error Reporting Tool</component>
          <version>1.7</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.8 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Richard Purdie">richard.purdie</reporter>
          <assigned_to name="Michael Wood">michael.g.wood</assigned_to>
          
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>48378</commentid>
    <comment_count>0</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2015-01-29 11:12:04 +0000</bug_when>
    <thetext>For example:

diff --git a/meta/recipes-extended/bash/bash_4.3.bb b/meta/recipes-extended/bash/bash_4.3.bb
index 23d3197..19b06a1 100644
--- a/meta/recipes-extended/bash/bash_4.3.bb
+++ b/meta/recipes-extended/bash/bash_4.3.bb
@@ -109,3 +109,8 @@ SRC_URI[patch030.md5sum] = &quot;efb709fdb1368945513de23ccbfae053&quot;
 SRC_URI[patch030.sha256sum] = &quot;85434f8a2f379d0c49a3ff6d9ffa12c8b157188dd739e556d638217d2a58385b&quot;
 
 BBCLASSEXTEND = &quot;nativesdk&quot;
+
+python do_test () {
+    bb.fatal(&quot;åäö&quot;)
+}
+addtask test

then bitbake bash -c test

NOTE: Executing RunQueue Tasks
ERROR: åäö
ERROR: Function failed: do_test
ERROR: Logfile of failure stored in: /media/build1/poky/build/tmp/work/i586-poky-linux/bash/4.3-r1/temp/log.do_test.26280
ERROR: Task 0 (/media/build1/poky/meta/recipes-extended/bash/bash_4.3.bb, do_test) failed with exit code &apos;1&apos;

You can send the errors to an upstream server by running:
  send-error-report /media/build1/poky/build/tmp/log/error-report/error_report_201501291053.txt [server]

$ send-error-report /media/build1/poky/build/tmp/log/error-report/error_report_201501291053.txt 

Sends an error report (if the report-error class was enabled) to a remote server.

This scripts sends the contents of the error to a public upstream server.

Please remove any identifying information before sending.
500 Internal Server Error
There was a problem submiting your data, response written in /media/build1/poky/build/tmp/log/error-report/error_report_201501291053.txt.response.html

There is also a problem with the report-error.bbclass itself, it calls jsondata[&apos;failures&apos;].append(taskdata) and if taskdata[&apos;log&apos;] had binary data in it, it could crash, there was no encoding.

You can demonstrate this with something like:

+python do_test () {
+    bindata = open(&quot;/bin/bash&quot;, &quot;rb&quot;).read()
+
+    bb.fatal(bindata)
+}

which obvioulsy messes up the console but you&apos;ll also see a traceback from the JSON code when the error-report function is called (you can look at the cooker logs in log/cooker/).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48379</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2015-01-29 11:15:39 +0000</bug_when>
    <thetext>An attempted fix which would require a change to the transmission format:

From 8ce292fb7e6c777918ea1f1e7fdd0a772f7066fc Mon Sep 17 00:00:00 2001
From: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
Date: Wed, 27 Aug 2014 14:16:58 +0000
Subject: report-error: Fix binary data encoding in logs

If the log file contains binary data the report-error class currently
crashes. This safely encodes the data to deal correctly with binary
characters.

Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;

diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
index 8b30422..6ba09eb 100644
--- a/meta/classes/report-error.bbclass
+++ b/meta/classes/report-error.bbclass
@@ -47,8 +47,8 @@ python errorreport_handler () {
             taskdata[&apos;package&apos;] = e.data.expand(&quot;${PF}&quot;)
             taskdata[&apos;task&apos;] = task
             if log:
-                logFile = open(log, &apos;r&apos;)
-                taskdata[&apos;log&apos;] = logFile.read()
+                logFile = open(log, &apos;rb&apos;)
+                taskdata[&apos;log&apos;] = logFile.read().encode(&apos;base64&apos;)
                 logFile.close()
             else:
                 taskdata[&apos;log&apos;] = &quot;No Log&quot;
-- 
cgit v0.10.2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48504</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Wood">michael.g.wood</who>
    <bug_when>2015-02-03 11:51:31 +0000</bug_when>
    <thetext>As discussed a try/except may actually be the best solution

http://lists.openembedded.org/pipermail/openembedded-core/2015-January/101204.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48523</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Wood">michael.g.wood</who>
    <bug_when>2015-02-03 17:46:32 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; As discussed a try/except may actually be the best solution
&gt; 
&gt; http://lists.openembedded.org/pipermail/openembedded-core/2015-January/
&gt; 101204.html

I&apos;ve added a v2 of the patch - I had meant to put the file open() inside the try as well so that any IOError would also be handled.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>