Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for static and dynamic analyzer tools.
https://codechecker.readthedocs.io
Apache License 2.0
2.28k stars 383 forks source link

AF_UNIX path too long when running CodeChecker analyze #1533

Open MarkZ3 opened 6 years ago

MarkZ3 commented 6 years ago

Using CodeChecker 6.5.1 My files are in path (I changed the name for the purpose of public report): /local/usernameeeeeee/cooooooooooooooooooooooooooooooooooooooooooooooooooode/llvm

with many sub-folders in there, as you would expect in LLVM code base.

$ CodeChecker analyze compilation.json -o ./reports

[INFO 2018-04-19 22:06] - Starting static analysis ... Process SyncManager-1: Traceback (most recent call last): File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/python/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap self.run() File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/python/lib/python2.7/multiprocessing/process.py", line 114, in run self._target(*self._args, *self._kwargs) File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/python/lib/python2.7/multiprocessing/managers.py", line 550, in _run_server server = cls._Server(registry, address, authkey, serializer) File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/python/lib/python2.7/multiprocessing/managers.py", line 162, in init self.listener = Listener(address=address, backlog=16) File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/python/lib/python2.7/multiprocessing/connection.py", line 132, in init self._listener = SocketListener(address, family, backlog) File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/python/lib/python2.7/multiprocessing/connection.py", line 256, in init self._socket.bind(address) File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/python/lib/python2.7/socket.py", line 228, in meth return getattr(self._sock,name)(args) error: AF_UNIX path too long Traceback (most recent call last): File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/cc_bin/CodeChecker.py", line 92, in main args.func(args) File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/lib/python2.7/libcodechecker/libhandlers/analyze.py", line 443, in main analyzer.perform_analysis(args, context, actions, metadata) File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/lib/python2.7/libcodechecker/analyze/analyzer.py", line 152, in perform_analysis manager = Manager() File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/python/lib/python2.7/multiprocessing/init.py", line 99, in Manager m.start() File "/local/usernameeeeeee/folderrrrrrrrrrrrrrrrrrrrrrrrrrr/CodeChecker/codechecker-64bit-6.5.1/python/lib/python2.7/multiprocessing/managers.py", line 528, in start self._address = reader.recv() EOFError

whisperity commented 6 years ago

This looks like an issue with Python itself. The exception is raised even before CodeChecker could try invoking clang or anything that is, at the point where the process pool for the analysis is created.

At this point, I can't seem to suggest anything better than setting up symbolic links and executing CodeChecker from there so the path is shorter (to see if it's only a Python thing or will Clang also unable to handle the already massive command line of analysis arguments coupled with massive paths!), or recompiling the kernel to allow longer paths and file descriptor names.

MarkZ3 commented 6 years ago

I looked a bit more into this. Using symbol links for CodeChecker or the analyzed code didn't seem to change the behavior. But looking at this more closely, the path of the socket is dependent on the temporary folder path. My Jenkins job sets a temp folder (TEMP, TMPDIR env var) within the workspace folder, which is longer than your typical /tmp. The max path seems to be tied to char sun_path[108], see http://man7.org/linux/man-pages/man7/unix.7.html For example, this path temp path: /tmpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp/ means a socket with this path: /tmpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp/tmpg19pn_/original_env.pickle which is: 109 - trailing slash - leading slash = 107 and this works! But if you add a single character to this temp path, then it breaks with the error above.

I don't really think it should be something fixed by CodeChecker, but maybe it could be in a FAQ or somewhere appropriate? Basically, the solution is to use a reasonably short temp folder path for sockets to reside in.