<?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>16242</bug_id>
          
          <creation_ts>2026-04-10 09:27:48 +0000</creation_ts>
          <short_desc>Unsafe usage of Python subunit module</short_desc>
          <delta_ts>2026-04-16 14:36:19 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>10</classification_id>
          <classification>QA/Testing</classification>
          <product>Functional (self) Testing</product>
          <component>oe-selftest</component>
          <version>6.0</version>
          <rep_platform>All</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>6.1 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Paul Barker">paul</reporter>
          <assigned_to name="Unassigned">unassigned</assigned_to>
          <cc>randy.macleod</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>105040</commentid>
    <comment_count>0</comment_count>
    <who name="Paul Barker">paul</who>
    <bug_when>2026-04-10 09:27:48 +0000</bug_when>
    <thetext>In https://autobuilder.yoctoproject.org/valkyrie/#/builders/97/builds/15 we saw a failure we have seen before, but it it&apos;s very rare.

```
2026-04-09 01:18:20,881 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File &quot;/srv/pokybuild/yocto-worker/bringup-fast/build/layers/openembedded-core/meta/lib/oeqa/core/utils/concurrencytest.py&quot;, line 234, in _run_test
    testserver.run(process_result)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File &quot;/usr/lib/python3/dist-packages/subunit/__init__.py&quot;, line 1219, in run
    protocol.lineReceived(line)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File &quot;/usr/lib/python3/dist-packages/subunit/__init__.py&quot;, line 583, in lineReceived
    self._state.lineReceived(line)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File &quot;/usr/lib/python3/dist-packages/subunit/__init__.py&quot;, line 422, in lineReceived
    self.details_parser.lineReceived(line)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File &quot;/usr/lib/python3/dist-packages/subunit/details.py&quot;, line 121, in lineReceived
    self._parse_state(line)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File &quot;/usr/lib/python3/dist-packages/subunit/details.py&quot;, line 104, in _feed_chunks
    residue = self._chunk_parser.write(line)
  File &quot;/usr/lib/python3/dist-packages/subunit/chunked.py&quot;, line 138, in write
    return self.state()
           ~~~~~~~~~~^^
  File &quot;/usr/lib/python3/dist-packages/subunit/chunked.py&quot;, line 108, in _read_length
    raise ValueError(&quot;chunk header invalid: %r&quot; % count_str)
ValueError: chunk header invalid: b&apos;\n&apos;
```
We use the python subunit module (https://github.com/testing-cabal/subunit) to run test cases in subprocesses. Communication of results from child processes back to the parent process uses subunit protocol v1 which is very fragile. It&apos;s a text based protocol relying on newlines to separate statements, with buffering involved that can complicate things further. We also multiplex the stdout and stderr streams from test cases over the same pipe back to the parent process. In theory, subunit supports this, but it&apos;s a disaster waiting to happen.

What has likely happened here is that a newline has been sent over the pipe by a test case when subunit was expecting a chunk header. This triggers a parsing error in the decoder in chunked.py.

We should move stdout and stderr off the pipe used to communicate test results. We can&apos;t discard this &quot;test noise&quot; as it is useful when trying to debug test failures. Instead we should create a separate pipe for this purpose and an additional thread in the parent process to drain this pipe in to the output stream. This requires a bit of work to ensure that the new thread is managed correctly (i.e. drained and shutdown when the parent process finishes). We don&apos;t want to rush this and get things wrong, so we will leave this until after the 6.0 release - the issue is very rare so hopefully it won&apos;t happen again too soon!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>