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

Docker container NullPointerException #19

Closed
ajhodges opened this issue Oct 1, 2018 · 9 comments
Closed

Docker container NullPointerException #19

ajhodges opened this issue Oct 1, 2018 · 9 comments
Labels
Bug Something isn't working Need Input Input needed to work on this issue

Comments

@ajhodges
Copy link

ajhodges commented Oct 1, 2018

Potentially related to #16? I am trying to build and run the Dockerfile from the current master@569893a. When I run it against the example it runs fine, but when I mount my sol files at /contracts I get this output:

[Ljava.lang.StackTraceElement;@6872f9c8
FAILURE
Exception in thread "main" java.lang.NullPointerException
	at ch.securify.analysis.Dataflow.dispose(Dataflow.java:43)
	at ch.securify.Main.checkPatterns(Main.java:397)
	at ch.securify.Main.processHexFile(Main.java:151)
	at ch.securify.Main.processSolidityFile(Main.java:108)
	at ch.securify.Main.main(Main.java:186)
Error: Exited with code 1
Step failed
Error: runner failed
Task failed
@hiqua
Copy link
Contributor

hiqua commented Oct 1, 2018

Are there sol files that you could share with us so that we can reproduce the issue? Given that it's within the docker image, Soufflé should be installed.

@ajhodges
Copy link
Author

ajhodges commented Oct 1, 2018

I can't share the sol files in question - but I can tell you that it is a Truffle + OpenZeppelin project that I have flattened using this project: https://github.com/BlockChainCompany/soljitsu

Haven't had any problems with other analysis tools; I will do some more debugging on my end and try to come up with a simple share-able example tomorrow. Thanks!

@hiqua
Copy link
Contributor

hiqua commented Oct 2, 2018

Ok I understand. Is the output of solc --combined-json abi,ast,bin-runtime,srcmap-runtime file.sol anything special, are there empty fields, etc?

As you can see from https://github.com/eth-sri/securify/blob/master/src/main/java/ch/securify/CompilationHelpers.java#L87 we only run solc under the hood. In the Dockerfile you can see that we still use v0.4.24 (I should update this by the way). Do your contracts compile with v0.4.24?

Can you copy paste the command you use exactly to mount your folder into the Docker container?

@hiqua hiqua added Bug Something isn't working Need Input Input needed to work on this issue labels Oct 2, 2018
@ajhodges
Copy link
Author

ajhodges commented Oct 2, 2018

Okay - I just spent a couple hours debugging. The root cause of this error is that I am running /docker_run_securify from a working directory other than root (/). So in

String cmd = TIMEOUT_COMMAND + " " + Config.PATTERN_TIMEOUT + "s " + SOUFFLE_BIN + " -w -F " + WORKSPACE + " -D " + WORKSPACE_OUT + " " + SOUFFLE_RULES;

SOUFFLE_RULES is set to smt_files/mustExplicit.dl, which is a relative path. So souffle is not finding it in my working directory and dying.

The reason why I am using a different working directory is because I am trying to get Securify running in CircleCI, which defaults to a working directory other than root.

I recommend using absolute paths for SOUFFLE_RULES to ensure this does not happen.

Also - there is a small bug in your error logging:

System.out.println(e.getStackTrace());

This just prints [Ljava.lang.StackTraceElement;@6872f9c8 as shown above in my original issue comment. It should be changed to
e.printStackTrace();

Once I changed my working directory to root /, I got Securify to get a little bit further in its analysis - I'll open a different issue for the next thing I encountered.

@hiqua
Copy link
Contributor

hiqua commented Oct 3, 2018

Do you mean that you have your own Dockerfile that takes the Securify image as its base, and that you change the working directory in this one?

@ajhodges
Copy link
Author

ajhodges commented Oct 3, 2018

No, sorry. I am building your Dockerfile and then running commands inside that container to check out my code instead of using a volume mount. It just so happens that the working directory of those commands wasn't /.

If you want to reproduce this, just add a -w flag to your docker run command, like:
docker run -w /home -v $(pwd)/folder_with_solidity_files:/contracts securify
or even just to run the example.sol:
docker run -w /home securify

@hiqua
Copy link
Contributor

hiqua commented Oct 3, 2018

Ok I see, but then is there something we can fix for this issue in particular?

@ajhodges
Copy link
Author

ajhodges commented Oct 3, 2018

I recommend using absolute paths for SOUFFLE_RULES, but it is up to you if this issue is serious enough to warrant a fix. I just wanted to make sure I documented it just in case someone else runs into this.

@hiqua
Copy link
Contributor

hiqua commented Oct 3, 2018

Absolute paths won't work outside of docker containers unfortunately.

@ajhodges ajhodges closed this as completed Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Need Input Input needed to work on this issue
Projects
None yet
Development

No branches or pull requests

2 participants