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

[Bug-Candidate]: Slither suddenly started failing when running #1324

Closed
Bolee95 opened this issue Aug 3, 2022 · 7 comments
Closed

[Bug-Candidate]: Slither suddenly started failing when running #1324

Bolee95 opened this issue Aug 3, 2022 · 7 comments

Comments

@Bolee95
Copy link

Bolee95 commented Aug 3, 2022

Describe the issue:

When trying to run Slither it fails without any concrete information but with the trace stack that I couldn't demystify.
Contracts compilation is successful as well as tests running.

Code example to reproduce the issue:

slither .

Version:

Slither 0.8.3
Hardhat 2.10.1
MacOS 12.5

Relevant log output:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/__main__.py", line 744, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/__main__.py", line 87, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/__main__.py", line 70, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/slither.py", line 95, in __init__
    parser.parse_top_level_from_loaded_json(ast, path)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 211, in parse_top_level_from_loaded_json
    contract.set_offset(top_level_data["src"], self._compilation_unit)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/core/source_mapping/source_mapping.py", line 124, in set_offset
    self._source_mapping = self._convert_source_mapping(offset, compilation_unit)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/core/source_mapping/source_mapping.py", line 101, in _convert_source_mapping
    (lines, starting_column, ending_column) = self._compute_line(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/core/source_mapping/source_mapping.py", line 43, in _compute_line
    end_line, ending_column = compilation_unit.core.crytic_compile.get_line_from_offset(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 291, in get_line_from_offset
    return lines_delimiters[offset]
KeyError: 511
None
Error in .
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/__main__.py", line 744, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/__main__.py", line 87, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/__main__.py", line 70, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/slither.py", line 95, in __init__
    parser.parse_top_level_from_loaded_json(ast, path)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 211, in parse_top_level_from_loaded_json
    contract.set_offset(top_level_data["src"], self._compilation_unit)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/core/source_mapping/source_mapping.py", line 124, in set_offset
    self._source_mapping = self._convert_source_mapping(offset, compilation_unit)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/core/source_mapping/source_mapping.py", line 101, in _convert_source_mapping
    (lines, starting_column, ending_column) = self._compute_line(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slither/core/source_mapping/source_mapping.py", line 43, in _compute_line
    end_line, ending_column = compilation_unit.core.crytic_compile.get_line_from_offset(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 291, in get_line_from_offset
    return lines_delimiters[offset]
KeyError: 511
@0xTimepunk
Copy link

@Bolee95 I have the same issue with the same versions of Slither Hardhat and MacOs

In my case it says KeyError: 12626

What to do?

@Bolee95
Copy link
Author

Bolee95 commented Aug 8, 2022

@0xTimepunk Not sure, I still haven't been able to make it work. I would assume these are internal identifiers of errors.

@0xalpharush
Copy link
Contributor

Can you show the output of crytic-compile .? Another thing to try is running npx hardhat clean and recompiling from scratch.

@0xalpharush 0xalpharush added Need more info and removed bug-candidate Bugs reports that are not yet confirmed labels Aug 10, 2022
@Bolee95
Copy link
Author

Bolee95 commented Aug 16, 2022

Hi @0xalpharush,
I tried it out again with the older codebase, where the issue was first detected, as well as with the new one. I was able to get a proper report, so I wasn't able to replicate this.
I haven't run npx hardhat clean before it.
The only notisable difference between when the issue was appearing and now is that I updated hardhat to 2.10.2, but I'm not sure if that could somehow solve it, as this version of hardhat doesn't bring any major changes.
@0xTimepunk How is it on your side?

@montyly
Copy link
Member

montyly commented Aug 16, 2022

@Bolee95 : it might be because of a cache issue in hardhat - it happens from time to time, where hardhat does not clean properly the compilation artefacts (despite slither providing a flag to do so)

@gretzke
Copy link

gretzke commented Sep 5, 2022

npx hardhat clean fixed the issue for me

@exd0tpy
Copy link

exd0tpy commented Sep 12, 2022

I got same issue on foundry project

I solved with this modification. This fix issue but all of the line number information will 0.

#1313 (comment)

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

No branches or pull requests

6 participants