Skip to content

ReFrame crashes when trying to print stdout/stderr of a file containing non-Unicode characters #3631

@vkarak

Description

@vkarak

Test to reproduce:

import reframe as rfm
import reframe.utility.sanity as sn


@rfm.simple_test
class MyTest(rfm.RunOnlyRegressionTest):
    valid_systems = ['*']
    valid_prog_environs = ['*']
    executable = 'printf'
    executable_opts = [r'"\xeb"']
    sanity_patterns = sn.assert_true(0)

Run as:

reframe -c /path/to/test.py -r
[==========] Running 1 check(s)
[==========] Started on Tue Feb 24 17:41:28 2026+0100

[----------] start processing checks
[ RUN      ] MyTest /e12e9e97 @generic:default+builtin
[     FAIL ] (1/1) MyTest /e12e9e97 @generic:default+builtin
==> test failed during 'sanity': test staged in '/tmp/rfm-stage/stage/generic/default/builtin/MyTest'
[----------] all spawned checks have finished

[  FAILED  ] Ran 1/1 test case(s) from 1 check(s) (1 failure(s), 0 expected failure(s), 0 skipped, 0 aborted)
[==========] Finished on Tue Feb 24 17:41:29 2026+0100
============================= SUMMARY OF FAILURES ==============================
--------------------------------------------------------------------------------
FAILURE INFO for MyTest (run: 1/1)
  * Description: 
  * System partition: generic:default
  * Environment: builtin
  * Test file: /path/to/test.py
  * Stage directory: /tmp/rfm-stage/stage/generic/default/builtin/MyTest
  * Node list: X99PTYQPKC
  * Job type: local (id=20654)
  * Dependencies (conceptual): []
  * Dependencies (actual): []
  * Maintainers: []
  * Failing phase: sanity
  * Rerun with '-n /e12e9e97 -p builtin --system generic -r'
Log file(s) saved in '/tmp/rfm-002lp63a.log'
Traceback (most recent call last):
  File "/path/to/reframe/reframe/frontend/cli.py", line 1770, in main
    printer.failure_report(
    ~~~~~~~~~~~~~~~~~~~~~~^
        report,
        ^^^^^^^
        rerun_info=not options.distribute,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        global_stats=options.duration or options.reruns
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/path/to/reframe/reframe/frontend/printer.py", line 187, in failure_report
    _print_failure_info(r, run_no, len(report['runs']))
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/reframe/reframe/frontend/printer.py", line 162, in _print_failure_info
    lines += _file_info(stdout, prefix=rec['stagedir']) + ['\n']
             ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/reframe/reframe/frontend/printer.py", line 115, in _file_info
    lines += osext.tail(os.path.join(prefix, filename), num_lines)
             ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/reframe/reframe/utility/osext.py", line 825, in tail
    return fp.readlines()[-num_lines:]
           ~~~~~~~~~~~~^^
  File "<frozen codecs>", line 325, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xeb in position 0: unexpected end of data

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/to/reframe/./bin/reframe", line 23, in <module>
    cli.main()
    ~~~~~~~~^^
  File "/path/to/reframe/reframe/core/logging.py", line 1126, in _fn
    return fn(*args, **kwargs)
  File "/path/to/reframe/reframe/frontend/cli.py", line 1874, in main
    message = f'run session stopped: {errors.what(*exc_info)}'
                                      ~~~~~~~~~~~^^^^^^^^^^^
  File "/path/to/reframe/reframe/core/exceptions.py", line 445, in what
    source = SourceCodeInfo(user_frame_from_tb(exc_type, exc_value, tb))
  File "/path/to/reframe/reframe/core/exceptions.py", line 86, in __init__
    self.__line = frame.code_context[frame.index]
                  ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Metadata

Metadata

Assignees

Type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions