GaloisInc / MATE

MATE is a suite of tools for interactive program analysis with a focus on hunting for bugs in C and C++ code using Code Property Graphs.
https://galoisinc.github.io/MATE/
BSD 3-Clause "New" or "Revised" License
177 stars 12 forks source link

SIGKILL while build process #59

Open drJabber opened 1 year ago

drJabber commented 1 year ago

Hello, Team, Great analysis tool, thank you!

Could you help me please to deal with haproxy analysis... or at least how to get more diagnostics to find errors I adapt haproxy makefile to compile with MATE (haproxy.tar.gz attached), than created artifact:

mate-cli artifact create compile-target:tarball haproxy.tar.gz

got { "artifact_id": "76e78253db7c4dc89fa43e4f0ec31ae9", "attributes": { "filename": "haproxy.tar.gz" }, "build_ids": [], "compilation_ids": [], "has_object": true, "kind": "compile-target:tarball" }

Than I compiled haproxy - successfully: mate-cli compile create --wait --artifact-id 76e78253db7c4dc89fa43e4f0ec31ae9 --make-targets all

got state "compiled": { "artifact_ids": [ "76e78253db7c4dc89fa43e4f0ec31ae9", "07e624b817d14ae297532714c916a1ab", "c7f74f4f1b734677be79b7ca84f1d873", "da921fd94c804a5a8ef4470af043f49f", "a19a76750b8b4862a0384c99d323c18e" ], "build_ids": [], "compilation_id": "99c3197dfbfa4feda4ed7ca82987c59a", "log_artifact": { "artifact_id": "07e624b817d14ae297532714c916a1ab", "attributes": { "filename": "compile.log" }, "build_ids": [], "compilation_ids": [ "99c3197dfbfa4feda4ed7ca82987c59a" ], "has_object": true, "kind": "compile-output:compile-log" }, "options": { "containerized": false, "containerized_infer_build": true, "docker_image": null, "experimental_embed_bitcode": false, "extra_compiler_flags": [], "make_targets": [ "all" ], "testbed": null }, "source_artifact": { "artifact_id": "76e78253db7c4dc89fa43e4f0ec31ae9", "attributes": { "filename": "haproxy.tar.gz" }, "build_ids": [], "compilation_ids": [ "99c3197dfbfa4feda4ed7ca82987c59a" ], "has_object": true, "kind": "compile-target:tarball" }, "state": "compiled" }

but when I tried to build haproxy - i got failed state What should I do to make process successfully finished?

After docker container logs mate_executor_1 I got error messages:

` [2022-10-23 10:07:06,466: DEBUG/ForkPoolWorker-1] waiting for build: build.uuid='9e66837900734413a413d50900b709e9' build.state=<BuildState.Building: 'building'>

[2022-10-23 10:07:11,372: ERROR/ForkPoolWorker-8] Task mate.tasks.build.build_artifact[c1ff0258-7649-479d-8bd6-bb4d59d577bf] raised unexpected: MateError('9e66837900734413a413d50900b709e9', '[PosixPath(\'/opt/mate/llvm-wedlock/bin/opt\'), \'-load\', PosixPath(\'/opt/mate/local/lib/libSoufflePA.so\'), \'-load\', PosixPath(\'/opt/mate/local/lib/libPAPass.so\'), \'-load\', PosixPath(\'/opt/mate/local/lib/libMATE.so\'), \'-disable-output\', \'-signatures=/tmp/tmpytz40zm7.json\', \'-time-passes=false\', \'-ast-graph-writer\', \'-pretty-llvm-value=true\', \'-datalog-pointer-analysis=true\', \'-mem-dep-edges=false\', \'-control-dep-edges=true\', \'-datalog-analysis=unification\', \'-debug-datalog=false\', \'-debug-datalog-dir=/tmp/tmpfgbuum3s/pa_results\', \'-check-datalog-assertions=false\', \'-context-sensitivity=2-callsite\', \'-cpg-file\', \'/tmp/tmp0gfyovjm.jsonl\', PosixPath(\'/tmp/tmpub_vmjt6.bc\')] exited due to signal SIGKILL (9);\n\nSTDOUT:\nb\'\'\n\nSTDERR:\nb\'Writing facts to: "/tmp/tmpfgbuum3s/pa_results"...\nfneg: Unhandled instruction\n\'') Traceback (most recent call last): File "/opt/mate/lib/python3.8/site-packages/celery/app/trace.py", line 451, in trace_task R = retval = fun(*args, *kwargs) File "/opt/mate/lib/python3.8/site-packages/celery/app/trace.py", line 734, in __protected_call__ return self.run(args, **kwargs) File "/opt/mate/local/lib/python3.8/site-packages/mate/tasks/build.py", line 49, in build_artifact mate_build.build_artifact(artifact, build, self.session, opts) File "/opt/mate/local/lib/python3.8/site-packages/mate/build/build.py", line 1002, in build_artifact raise e File "/opt/mate/local/lib/python3.8/site-packages/mate/build/build.py", line 992, in build_artifact (_new_artifacts, _graph) = builder.build_artifact(artifact, session) File "/opt/mate/local/lib/python3.8/site-packages/mate/build/build.py", line 617, in build_artifact mate_jsonl = self._build_mate_jsonl(Path(canonicalized_bc.name)) File "/opt/mate/local/lib/python3.8/site-packages/mate/build/build.py", line 458, in _build_mate_jsonl raise CPGBuildError.from_process_error(e, build_id=self._build.uuid) mate_common.error.MateError: ('9e66837900734413a413d50900b709e9', '[PosixPath(\'/opt/mate/llvm-wedlock/bin/opt\'), \'-load\', PosixPath(\'/opt/mate/local/lib/libSoufflePA.so\'), \'-load\', PosixPath(\'/opt/mate/local/lib/libPAPass.so\'), \'-load\', PosixPath(\'/opt/mate/local/lib/libMATE.so\'), \'-disable-output\', \'-signatures=/tmp/tmpytz40zm7.json\', \'-time-passes=false\', \'-ast-graph-writer\', \'-pretty-llvm-value=true\', \'-datalog-pointer-analysis=true\', \'-mem-dep-edges=false\', \'-control-dep-edges=true\', \'-datalog-analysis=unification\', \'-debug-datalog=false\', \'-debug-datalog-dir=/tmp/tmpfgbuum3s/pa_results\', \'-check-datalog-assertions=false\', \'-context-sensitivity=2-callsite\', \'-cpg-file\', \'/tmp/tmp0gfyovjm.jsonl\', PosixPath(\'/tmp/tmpub_vmjt6.bc\')] exited due to signal SIGKILL (9);\n\nSTDOUT:\nb\'\'\n\nSTDERR:\nb\'Writing facts to: "/tmp/tmpfgbuum3s/pa_results"...\nfneg: Unhandled instruction\n\'')

[2022-10-23 10:07:11,381: DEBUG/ForkPoolWorker-8] http://storage:9000 "PUT /artifacts/6cfabc5ea6fe4c66973e1cfefbf9a6b0 HTTP/1.1" 200 0

[2022-10-23 10:07:11,474: WARNING/ForkPoolWorker-1] got failed state for build, not running analyses: build.uuid='9e66837900734413a413d50900b709e9' build.state=<BuildState.Failed: 'failed'>

[2022-10-23 10:07:11,483: INFO/ForkPoolWorker-1] Task mate.tasks.build.await_built_state_and_start_all_analyses[1de85dcd-507c-4fac-ae8d-3633cbccd8ab] succeeded in 2292.0805339869694s: None

[2022-10-23 10:07:11,484: ERROR/ForkPoolWorker-1] probable API misuse: task didn't take a build_id kwarg `

langston-barrett commented 1 year ago

This part of the error message comes from the pointer analysis, I've filed an issue on that repo.

fneg: Unhandled instruction

However, that error isn't fatal, so I don't think it's causing the issue.

The part about SIGKILL suggests that this might be an out-of-memory issue, which likely stems from the pointer analysis. @drJabber Take a look at this page in the documentation: https://galoisinc.github.io/MATE/debugging-builds.html. You might try increasing memory_limit_mb or changing pointer_analysis to the unification-based analysis.

In particular, you might try something like

mate-cli build create --pointer-analysis unification --context-sensitivity insensitive --memory-limit-mb 64000 ...

Any of those flags individually might help (the last one will only help if you have >32GB of RAM, though!)

langston-barrett commented 1 year ago

@drJabber Were you able to get this working?