scancode aborts when encountering a broken RPM archive

Open Beginner friendly
#5,407 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@Ashutosh-Panda2004 is already working on this.

Since Nov 4, 2026.

  • #5417 by @Ashutosh-Panda2004 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
tooling

Research direction

The traceback points to src/packagedcode/rpm.py, where get_rpm_tags (around line 87) builds RPM(rpmf) and parse (around line 293) calls it, and to src/packagedcode/pyrpm.py, where read_lead (around line 425) raises RPMError on a wrong magic number. Start by reproducing the crash on the suspected tests/data/archive.rpm from fuse-archive. Done means the scan no longer aborts or hangs on a non-RPM file, the error is handled or skipped, and the worker pool keeps going.

Written by the indexing model from the issue text.

Description

bug

While scanning the fuse-archive 1.22 source directory in a yocto build, scancode crashes and hangs forever:

Process ForkPoolWorker-15:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/local/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.12/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/scancode-toolkit/src/scancode/cli.py", line 1456, in scan_resource
    error, values_mapping = interruptor(runner, timeout=timeout)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scancode-toolkit/src/scancode/interrupt.py", line 91, in interruptible
    return NO_ERROR, func(*(args or ()), **(kwargs or {}))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scancode-toolkit/src/scancode/api.py", line 327, in get_package_data
    package_datas = _get_package_data(
                    ^^^^^^^^^^^^^^^^^^
  File "/scancode-toolkit/src/scancode/api.py", line 276, in _get_package_data
    return recognize_package_data(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/scancode-toolkit/src/packagedcode/recognize.py", line 62, in recognize_package_data
    return list(_parse(
           ^^^^^^^^^^^^
  File "/scancode-toolkit/src/packagedcode/recognize.py", line 136, in _parse
    for parsed in handler.parse(location=location, package_only=package_only):
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scancode-toolkit/src/packagedcode/rpm.py", line 293, in parse
    rpm_tags = get_rpm_tags(location, include_desc=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scancode-toolkit/src/packagedcode/rpm.py", line 87, in get_rpm_tags
    rpm = RPM(rpmf)
          ^^^^^^^^^
  File "/scancode-toolkit/src/packagedcode/pyrpm.py", line 399, in __init__
    self.read_lead()
  File "/scancode-toolkit/src/packagedcode/pyrpm.py", line 425, in read_lead
    raise RPMError('Wrong magic number: this is not a RPM file')
packagedcode.pyrpm.RPMError: Wrong magic number: this is not a RPM file

The offending file might be https://github.com/google/fuse-archive/blob/main/tests/data/archive.rpm.

Dominant language
Python
Stars
2.7k
Forks
871
Avg merge
1d 10h
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aboutcode-org/scancode-toolkit

All issues in aboutcode-org/scancode-toolkit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.