echidna icon indicating copy to clipboard operation
echidna copied to clipboard

Bug: Missing error message if slither fails

Open rappie opened this issue 2 years ago • 10 comments

It only shows there is an error. Not the specific error that slither returns.

$ echidna-test . --contract E2E --config echidna-config.yaml
Loaded total of 0 transactions from echidna-corpus/coverage
Analyzing contract: /home/rappie/<snip>/E2E.sol:E2E
echidna-test: Error running slither:

rappie avatar Jun 07 '22 09:06 rappie

This is a good catch. I will create a PR for this soon.

ggrieco-tob avatar Jun 07 '22 09:06 ggrieco-tob

Uhm, we already have some code for this. Are you sure you don't have a command named "slither" in your path?

-- Slither processing
runSlither :: (MonadIO m, MonadThrow m) => FilePath -> [String] -> m SlitherInfo
runSlither fp extraArgs = if ".vy" `isSuffixOf` pack fp then return noInfo else do
  mp <- liftIO $ findExecutable "slither"
  case mp of
    Nothing -> throwM $ ProcessorNotFound "slither" "You should install it using 'pip3 install slither-analyzer --user'"

ggrieco-tob avatar Jun 07 '22 11:06 ggrieco-tob

Slither works fine

$ slither --version
0.8.3

$ which slither
/home/rappie/.local/bin/slither

$ echo $PATH
/home/rappie/go/bin:/usr/lib/go/bin:/home/rappie/.yarn/bin:/home/rappie/.config/yarn/global/node_modules/.bin:/home/rappie/.local/bin:/home/rappie/go/bin:/usr/lib/go/bin:/home/rappie/.yarn/bin:/home/rappie/.config/yarn/global/node_modules/.bin:/home/rappie/.local/bin:/home/rappie/.nvm/versions/node/v14.19.0/bin:/opt/jython/bin/:/home/rappie/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin

rappie avatar Jun 07 '22 11:06 rappie

Can we see what happens if you run the slither printer directly from the command line? (slither . --print echidna)

ggrieco-tob avatar Jun 07 '22 12:06 ggrieco-tob

Well, the thing is.. I don't know how to reproduce the error. I've tried it many times already. I've actually been waiting for it to happen again and posted this as soon as it did :smile:

Running npx hardhat clean fixes it.

I know it has something to do with compiled contracts being out of sync or something. Last time it happened when my E2E contract turned out to have compilation errors.

Next time I get the error i'll keep a corrupted copy of the project so we can experiment more.

rappie avatar Jun 07 '22 12:06 rappie

Oh, that's fine. Let's keep this open, just in case.

ggrieco-tob avatar Jun 07 '22 13:06 ggrieco-tob

We're in luck. I got one again right away :smile:

$ slither . --print echidna
'npx hardhat compile --force' running


DeclarationError: Undeclared identifier.
  --> contracts/Target.sol:11:14:
   |
11 |         emit SenderAddress(msg.sender);
   |              ^^^^^^^^^^^^^


Error HH600: Compilation failed
For more info go to https://hardhat.org/HH600 or run Hardhat with --show-stack-traces

Traceback (most recent call last):
  File "/home/rappie/.local/lib/python3.10/site-packages/slither/__main__.py", line 744, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/rappie/.local/lib/python3.10/site-packages/slither/__main__.py", line 87, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/rappie/.local/lib/python3.10/site-packages/slither/__main__.py", line 70, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/rappie/.local/lib/python3.10/site-packages/slither/slither.py", line 95, in __init__
    parser.parse_top_level_from_loaded_json(ast, path)
  File "/home/rappie/.local/lib/python3.10/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 "/home/rappie/.local/lib/python3.10/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 "/home/rappie/.local/lib/python3.10/site-packages/slither/core/source_mapping/source_mapping.py", line 101, in _convert_source_mapping
    (lines, starting_column, ending_column) = self._compute_line(
  File "/home/rappie/.local/lib/python3.10/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 "/home/rappie/.local/lib/python3.10/site-packages/crytic_compile/crytic_compile.py", line 291, in get_line_from_offset
    return lines_delimiters[offset]
KeyError: 294
None
Error in .
Traceback (most recent call last):
  File "/home/rappie/.local/lib/python3.10/site-packages/slither/__main__.py", line 744, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/rappie/.local/lib/python3.10/site-packages/slither/__main__.py", line 87, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/rappie/.local/lib/python3.10/site-packages/slither/__main__.py", line 70, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/rappie/.local/lib/python3.10/site-packages/slither/slither.py", line 95, in __init__
    parser.parse_top_level_from_loaded_json(ast, path)
  File "/home/rappie/.local/lib/python3.10/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 "/home/rappie/.local/lib/python3.10/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 "/home/rappie/.local/lib/python3.10/site-packages/slither/core/source_mapping/source_mapping.py", line 101, in _convert_source_mapping
    (lines, starting_column, ending_column) = self._compute_line(
  File "/home/rappie/.local/lib/python3.10/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 "/home/rappie/.local/lib/python3.10/site-packages/crytic_compile/crytic_compile.py", line 291, in get_line_from_offset
    return lines_delimiters[offset]
KeyError: 294

rappie avatar Jun 07 '22 14:06 rappie

This bug in crytic-compile could be related: https://github.com/crytic/crytic-compile/issues/268#issuecomment-1148811977

rappie avatar Jun 07 '22 15:06 rappie

Want me to test something else or can I delete my broken project directory copy that has this error?

rappie avatar Jun 16 '22 10:06 rappie

I think you can delete it, this is somehow a known issue related with hardhat :disappointed:

ggrieco-tob avatar Sep 09 '22 11:09 ggrieco-tob

Hey, this is still happening to me, I narrowed it down to a big contract that needs to use solc-arg "optimize" to be successfully compiled.

But the slither still fails with no error. Any ideas?

mariobyn avatar Oct 15 '22 10:10 mariobyn

We already added code to make sure slither errors are printed. Please reopen if this is not working as expected

ggrieco-tob avatar Sep 01 '23 16:09 ggrieco-tob