<?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>14542</bug_id>
          
          <creation_ts>2021-09-03 11:46:48 +0000</creation_ts>
          <short_desc>Three copies of output from failing task</short_desc>
          <delta_ts>2021-09-11 21:41:24 +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>unspecified</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>3.4 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Martin Jansa">Martin.Jansa</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
    
    <cc>yocto</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>91337</commentid>
    <comment_count>0</comment_count>
    <who name="Martin Jansa">Martin.Jansa</who>
    <bug_when>2021-09-03 11:46:48 +0000</bug_when>
    <thetext>It was originally reported by Mike Crowe on bitbake-devel in:
https://lists.openembedded.org/g/bitbake-devel/message/12144

His analysis:
  Even if I set BBINCLUDELOGS=&quot;no&quot;, I still get these three copies.

  The first one (without the leading &quot;|&quot; characters) appears to come from
  _build.py:_exec_task (around line 702) executing logger.error(str(exc)).
  This line dates from 2011.

  The second and third ones (with the leading &quot;|&quot;) come from knotty.py around
  line 767. They are both in log.do_configure.32031. It looks like the third
  copy is coming from the same place as the first copy, but has been written
  to both the console and the log file.

  If I comment out the previously-mentioned call to logger.error(str(exc)) in
  _build.py:_exec_task then I get the single copy of the task output as I
  would expect.

With simple test recipe:

$ cat openembedded-core/meta/recipes-core/failing/one.bb
SUMMARY = &quot;Destined to fail&quot;
LICENSE = &quot;CLOSED&quot;

deltask do_patch
INHIBIT_DEFAULT_DEPS = &quot;1&quot;

do_configure() {
        echo &quot;This is stdout&quot;
        echo &quot;This is stderr&quot; &gt;&amp;2
        exit 1
}

$ bitbake one -c configure
...
NOTE: Executing Tasks
ERROR: one-1.0-r0 do_configure: Execution of &apos;/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/run.do_configure.1956426&apos; failed with exit code 1:
This is stdout
This is stderr
WARNING: exit code 1 from a shell command.

ERROR: Logfile of failure stored in: /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/log.do_configure.1956426
Log data follows:
| DEBUG: Executing python function extend_recipe_sysroot
| NOTE: Direct dependencies are [&apos;virtual:native:/OE/build/oe-core/openembedded-core/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot&apos;]
| NOTE: Installed into sysroot: []
| NOTE: Skipping as already exists in sysroot: [&apos;pseudo-native&apos;]
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_configure
| This is stdout
| This is stderr
| WARNING: exit code 1 from a shell command.
| ERROR: Execution of &apos;/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/run.do_configure.1956426&apos; failed with exit code 1:
| This is stdout
| This is stderr
| WARNING: exit code 1 from a shell command.
| 
ERROR: Task (/OE/build/oe-core/openembedded-core/meta/recipes-core/failing/one.bb:do_configure) failed with exit code &apos;1&apos;
NOTE: Tasks Summary: Attempted 107 tasks of which 106 didn&apos;t need to be rerun and 1 failed.

with -v it gets even worse and the output is shown 5 times:

NOTE: one-1.0-r0 do_configure: Direct dependencies are [&apos;virtual:native:/OE/build/oe-core/openembedded-core/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot&apos;]
NOTE: one-1.0-r0 do_configure: Installed into sysroot: []
NOTE: one-1.0-r0 do_configure: Skipping as already exists in sysroot: [&apos;pseudo-native&apos;]
+ cd /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/one-1.0
+ do_configure
+ echo This is stdout
This is stdout
+ echo This is stderr
This is stderr
+ exit 1
+ bb_sh_exit_handler
+ ret=1
+ [ 1 != 0 ]
+ echo WARNING: exit code 1 from a shell command.
WARNING: exit code 1 from a shell command.
+ exit 1

ERROR: one-1.0-r0 do_configure: Execution of &apos;/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/run.do_configure.1956968&apos; failed with exit code 1:
+ cd /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/one-1.0
+ do_configure
+ echo This is stdout
This is stdout
+ echo This is stderr
This is stderr
+ exit 1
+ bb_sh_exit_handler
+ ret=1
+ [ 1 != 0 ]
+ echo WARNING: exit code 1 from a shell command.
WARNING: exit code 1 from a shell command.
+ exit 1

ERROR: Logfile of failure stored in: /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/log.do_configure.1956968
Log data follows:
| DEBUG: Executing python function extend_recipe_sysroot
| NOTE: Direct dependencies are [&apos;virtual:native:/OE/build/oe-core/openembedded-core/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot&apos;]
| NOTE: Installed into sysroot: []
| NOTE: Skipping as already exists in sysroot: [&apos;pseudo-native&apos;]
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_configure
| + cd /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/one-1.0
| + do_configure
| + echo This is stdout
| This is stdout
| + echo This is stderr
| This is stderr
| + exit 1
| + bb_sh_exit_handler
| + ret=1
| + [ 1 != 0 ]
| + echo WARNING: exit code 1 from a shell command.
| WARNING: exit code 1 from a shell command.
| + exit 1
| 
| + cd /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/one-1.0
| + do_configure
| + echo This is stdout
| This is stdout
| + echo This is stderr
| This is stderr
| + exit 1
| + bb_sh_exit_handler
| + ret=1
| + [ 1 != 0 ]
| + echo WARNING: exit code 1 from a shell command.
| WARNING: exit code 1 from a shell command.
| + exit 1
| ERROR: Execution of &apos;/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/run.do_configure.1956968&apos; failed with exit code 1:
| + cd /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/one-1.0
| + do_configure
| + echo This is stdout
| This is stdout
| + echo This is stderr
| This is stderr
| + exit 1
| + bb_sh_exit_handler
| + ret=1
| + [ 1 != 0 ]
| + echo WARNING: exit code 1 from a shell command.
| WARNING: exit code 1 from a shell command.
| + exit 1
|
ERROR: Task (/OE/build/oe-core/openembedded-core/meta/recipes-core/failing/one.bb:do_configure) failed with exit code &apos;1&apos;

This was with default BBINCLUDELOGS(&quot;yes&quot;), BBINCLUDELOGS_LINES(unset), BB_LOGCONFIG(unset), BB_CONSOLELOG(&quot;${LOG_DIR}/cooker/${MACHINE}/${DATETIME}.log&quot;

This gets worse when the failed tasks log file is huge (like 50MB log.do_compile file from chromium-x11 build when it gets tripped in cooker output).

It&apos;s also a bit unfortunate that setting BBINCLUDELOGS to &quot;no&quot; doesn&apos;t work, because any non-empty value will work as enabled in lib/bb/ui/knotty.py: &quot;if includelogs and not event.errprinted&quot;

With BBINCLUDELOGS set to empty the output is reasonable:

$ bitbake one -c configure
NOTE: Executing Tasks
ERROR: one-1.0-r0 do_configure: Execution of &apos;/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/run.do_configure.1960559&apos; failed with exit code 1:
This is stdout
This is stderr
WARNING: exit code 1 from a shell command.

ERROR: Logfile of failure stored in: /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/log.do_configure.1960559
ERROR: Task (/OE/build/oe-core/openembedded-core/meta/recipes-core/failing/one.bb:do_configure) failed with exit code &apos;1&apos;

And with -v it&apos;s only doubled (2nd one is printed on stderr)

$ bitbake one -c configure -v
...
NOTE: one-1.0-r0 do_configure: Direct dependencies are [&apos;virtual:native:/OE/build/oe-core/openembedded-core/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot&apos;]
NOTE: one-1.0-r0 do_configure: Installed into sysroot: []
NOTE: one-1.0-r0 do_configure: Skipping as already exists in sysroot: [&apos;pseudo-native&apos;]
+ cd /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/one-1.0
+ do_configure
+ echo This is stdout
This is stdout
+ echo This is stderr
This is stderr
+ exit 1
+ bb_sh_exit_handler
+ ret=1
+ [ 1 != 0 ]
+ echo WARNING: exit code 1 from a shell command.
WARNING: exit code 1 from a shell command.
+ exit 1

ERROR: one-1.0-r0 do_configure: Execution of &apos;/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/run.do_configure.1960937&apos; failed with exit code 1:
+ cd /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/one-1.0
+ do_configure
+ echo This is stdout
This is stdout
+ echo This is stderr
This is stderr
+ exit 1
+ bb_sh_exit_handler
+ ret=1
+ [ 1 != 0 ]
+ echo WARNING: exit code 1 from a shell command.
WARNING: exit code 1 from a shell command.
+ exit 1

ERROR: Logfile of failure stored in: /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/log.do_configure.1960937
ERROR: Task (/OE/build/oe-core/openembedded-core/meta/recipes-core/failing/one.bb:do_configure) failed with exit code &apos;1&apos;

If only stdout or stderr is shown, then the output looks a bit strange in both cases:

$ bitbake one -c configure 2&gt;/dev/null
...
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 107 tasks of which 106 didn&apos;t need to be rerun and 1 failed.
NOTE: Writing buildhistory
NOTE: Writing buildhistory took: 2 seconds
NOTE: Uploading the report /OE/build/oe-core/tmp-glibc/log/error-report/error_report_20210903114242.txt to errors.yoctoproject.org:80
NOTE: Report submitted: 200 Your entry can be found here: http://errors.yoctoproject.org/Errors/Build/129779/

Summary: 1 task failed:
  /OE/build/oe-core/openembedded-core/meta/recipes-core/failing/one.bb:do_configure

$ bitbake one -c configure 1&gt;/dev/null
ERROR: one-1.0-r0 do_configure: Execution of &apos;/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/run.do_configure.1961690&apos; failed with exit code 1:
This is stdout
This is stderr
WARNING: exit code 1 from a shell command.

ERROR: Logfile of failure stored in: /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/one/1.0-r0/temp/log.do_configure.1961690
ERROR: Task (/OE/build/oe-core/openembedded-core/meta/recipes-core/failing/one.bb:do_configure) failed with exit code &apos;1&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91338</commentid>
    <comment_count>1</comment_count>
    <who name="Martin Jansa">Martin.Jansa</who>
    <bug_when>2021-09-03 11:56:35 +0000</bug_when>
    <thetext>RFC work around sent to ML: https://lists.openembedded.org/g/openembedded-core/message/155650</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91354</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-09-07 21:21:38 +0000</bug_when>
    <thetext>I can&apos;t help wondering if we should remove that variable entirely...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91373</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-09-10 08:46:18 +0000</bug_when>
    <thetext>It is interesting to compare/contrast this with a python function like:

python do_configure () {
    print(&quot;Some output&quot;)
    sys.exit(1)
}

or

python do_configure () {
    print(&quot;Some output&quot;)
    bb.fatal(&quot;Fatal error&quot;)
}

I had thought this change would stop showing task output for the python case but it seems that isn&apos;t shown regardless of what BBINCLUDELOGS is set to.

So it looks like shell task logs are printed regardless and python tasks aren&apos;t at all. What a mess :(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91374</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-09-10 09:18:26 +0000</bug_when>
    <thetext>I dug into this a bit further. I have a couple of patches, one to fix python logging, the other to hide bb.process.run() output if piped logging is in use.

I think with those two fixes, we can turn BBINCLUDELOGS back on and things will work as expected with a single backtrace of the logs for both shell and python tasks.

This means with those two applied, I&apos;d revert the BBINCLUDELOGS default change as I think this is the better set of fixes.

Testing/feedback welcome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91375</commentid>
    <comment_count>5</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-09-10 09:30:33 +0000</bug_when>
    <thetext>I&apos;ve also sent a further patch to make -v not include a further copy of the info.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91376</commentid>
    <comment_count>6</comment_count>
    <who name="Martin Jansa">Martin.Jansa</who>
    <bug_when>2021-09-10 10:03:33 +0000</bug_when>
    <thetext>I&apos;ve repeated my test with one.bb with the BBINCLUDELOGS patch reverted and replaced with top 3 patches from your contrib/rpurdie/t222 and it seems to work fine.

Thanks</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91390</commentid>
    <comment_count>7</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-09-11 21:41:24 +0000</bug_when>
    <thetext>http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=ba4a61e69cd4035b5cdaa6cdf6be538af5ddaabb
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=f49854c1f7b7ab72c803864ab7f4c782fc503ca0
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=c2b40b0f6d062c5061b11b038fac3b7b1539c688</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>