Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to inspect ELF binaries #1121

Closed
2 tasks done
pombredanne opened this issue Mar 19, 2024 · 1 comment
Closed
2 tasks done

Failure to inspect ELF binaries #1121

pombredanne opened this issue Mar 19, 2024 · 1 comment

Comments

@pombredanne
Copy link
Member

pombredanne commented Mar 19, 2024

When scanning https://repo1.maven.org/maven2/com/sun/jna/jna/3.0.9/jna-3.0.9.jar
with scan_single_package, followed by inspect_elf_binaries inspect_elf_binaries fails with trace pasted below

We have two issues here:

In ScanCode.io:

Unsupported relocation type: 22

Traceback:
  File "/opt/scancodeio/scanpipe/pipelines/__init__.py", line 191, in execute
    step(self)
  File "/opt/scancodeio/scanpipe/pipelines/inspect_elf_binaries.py", line 46, in collect_dwarf_source_path_references
    dwarf_paths = get_dwarf_paths(Path(self.project.codebase_path / elf.path))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/scancodeio/venv/lib/python3.11/site-packages/elf_inspector/dwarf.py", line 41, in get_dwarf_paths
    for ptype, path in get_dwarf_cu_and_die_paths(location):
  File "/opt/scancodeio/venv/lib/python3.11/site-packages/elf_inspector/dwarf.py", line 74, in get_dwarf_cu_and_die_paths
    dwarfinfo = elffile.get_dwarf_info()
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/scancodeio/venv/lib/python3.11/site-packages/elftools/elf/elffile.py", line 275, in get_dwarf_info
    dwarf_section = self._read_dwarf_section(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/scancodeio/venv/lib/python3.11/site-packages/elftools/elf/elffile.py", line 801, in _read_dwarf_section
    reloc_handler.apply_section_relocations(
  File "/opt/scancodeio/venv/lib/python3.11/site-packages/elftools/elf/relocation.py", line 238, in apply_section_relocations
    self._do_apply_relocation(stream, reloc, symtab)
  File "/opt/scancodeio/venv/lib/python3.11/site-packages/elftools/elf/relocation.py", line 293, in _do_apply_relocation
    raise ELFRelocationError(

In bare ScanCode toolkit:

pip install scancode-toolkit elf-inspector
scancode --dwarf --yaml - --verbose com/sun/jna/ 

I get this:

Scanning done.
Some files failed to scan properly:
Path: jna/sunos-sparcv9/libjnidispatch.so
  ERROR: for scanner: dwarf-inspector:
  ERROR: Unknown error:
  Traceback (most recent call last):
    File "/tmp/foo/tmp/jna-3.0.9/venv/lib/python3.10/site-packages/scancode/interrupt.py", line 91, in interruptible
      return NO_ERROR, func(*(args or ()), **(kwargs or {}))
    File "/tmp/foo/tmp/jna-3.0.9/venv/lib/python3.10/site-packages/elf_inspector/plugin_dwarf.py", line 54, in get_dwarfs
      return dict(dwarf_source_paths=get_dwarf_paths(location))
    File "/tmp/foo/tmp/jna-3.0.9/venv/lib/python3.10/site-packages/elf_inspector/dwarf.py", line 41, in get_dwarf_paths
      for ptype, path in get_dwarf_cu_and_die_paths(location):
    File "/tmp/foo/tmp/jna-3.0.9/venv/lib/python3.10/site-packages/elf_inspector/dwarf.py", line 74, in get_dwarf_cu_and_die_paths
      dwarfinfo = elffile.get_dwarf_info()
    File "/tmp/foo/tmp/jna-3.0.9/venv/lib/python3.10/site-packages/elftools/elf/elffile.py", line 275, in get_dwarf_info
      dwarf_section = self._read_dwarf_section(
    File "/tmp/foo/tmp/jna-3.0.9/venv/lib/python3.10/site-packages/elftools/elf/elffile.py", line 801, in _read_dwarf_section
      reloc_handler.apply_section_relocations(
    File "/tmp/foo/tmp/jna-3.0.9/venv/lib/python3.10/site-packages/elftools/elf/relocation.py", line 238, in apply_section_relocations
      self._do_apply_relocation(stream, reloc, symtab)
    File "/tmp/foo/tmp/jna-3.0.9/venv/lib/python3.10/site-packages/elftools/elf/relocation.py", line 293, in _do_apply_relocation
      raise ELFRelocationError(
  elftools.common.exceptions.ELFRelocationError: Unsupported relocation type: 22
tdruez added a commit that referenced this issue Mar 19, 2024
Signed-off-by: tdruez <tdruez@nexb.com>
tdruez added a commit that referenced this issue Mar 19, 2024
tdruez added a commit that referenced this issue Mar 19, 2024
Signed-off-by: tdruez <tdruez@nexb.com>
tdruez added a commit that referenced this issue Mar 19, 2024
Signed-off-by: tdruez <tdruez@nexb.com>
@tdruez
Copy link
Contributor

tdruez commented Mar 19, 2024

@pombredanne implemented in #1123

From the changelog:

  • Capture errors during the inspect_elf_binaries pipeline execution.
    Errors on resource inspection are stored as project error message instead of global
    pipeline failure.
    The problematic resource path is stored in the message details and displayed in the
    message list UI as a link to the resource details view.

Screenshot 2024-03-19 at 17 24 43

@tdruez tdruez closed this as completed Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants