Skip to content

test_profiling.test_sampling_profiler: Assertion failed: maxchar <= 0x10ffff on ARM64 Raspbian 3.x #159398

Open

Description

@vstinner

The error occurred in export(), in Lib/profiling/sampling/stack_collector.py, line 56:

class CollapsedStackCollector(StackTraceCollector):
    def export(self, filename):
        ...
        for (call_tree, thread_id), count in self.stack_counter.items():
            ...
            for file, line, func in call_tree:
                    ...
                    part = f"{os.path.basename(file)}:{func}:{line}"  # <========== HERE
                    ...

The func variables seems to contain only junk data. I understand that we have:

  • os.path.basename(file) = <unknown file>
  • file = \U916c3950U\x08\x00â�º\x00\Uab184910\x7f (junk data, invalid Unicode characters)
  • lineno = 0

The root cause is that the sampling profiler creates Unicode strings (function names) which contains invalid characters: characters bigger than _Py_MAX_UNICODE (0x10ffff).

ARM64 Raspbian 3.x: https://buildbot.python.org/#/builders/1678/builds/3979

test_sampling_with_collapsed_export (test.test_profiling.test_sampling_profiler.test_integration.TestSampleProfilerIntegration.test_sampling_with_collapsed_export) ...

Objects/unicodeobject.c:675: _PyUnicode_CheckConsistency: Assertion failed: maxchar <= 0x10ffff
Enable tracemalloc to get the memory block allocation traceback

object address  : 0x7fb533a830
object refcount : 1
object type     : 0x5573760d90
object type name: str
object repr     : '<unknown file>:\U916c3950U\x08\x00�\x00\Uab184910\x7f:0'

Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized

Current thread 0x0000007fb7952040 [python] (most recent call first):
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/profiling/sampling/stack_collector.py", line 56 in export
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/test/test_profiling/test_sampling_profiler/test_integration.py", line 484 in test_sampling_with_collapsed_export
  File "/home/stan/buildarea/3.x.stan-raspbian.nondebug/build/Lib/unittest/case.py", line 637 in _callTestMethod
  ...
  File "<frozen runpy>", line 87 in _run_code
  File "<frozen runpy>", line 201 in _run_module_as_main

Extension modules: _testcapi, _testinternalcapi (total: 2)

cc @pablogsal @StanFromIreland

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions