-1

I installed a package on my linux machine. When I run the installed binary, it hangs:

$installedBinary --help

is supposed to return a list of command line options. Instead, the program hangs and doesn't respond. It closes when I run control+c.

How can I investigate this problem?

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
kilojoules
  • 9,768
  • 18
  • 77
  • 149

2 Answers2

4

Start with strace -ffo traces ./installedBinary --help. And then inspect traces.* log files, in particular the last lines where it may show what it is blocked on. See strace(1)

You can also do that from htop. Locate the blocked thread and press s for strace and l for lsof.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271
0

Maxim Egorushkin's answer is a good one. But on Linux, most programs have some documentation (often, at least a man page, see man(1) & man(7)), and most programs are free software. And the documentation should tell a lot more than --help does (the output of --help is a short summary of the documentation; for example sed(1) explains a lot more than sed --help). Maybe the behavior of your program is explained in the documentation (e.g. depends upon some environment variable).

So you should also read the documentation of your installedBinary and you probably could get its source code, study and recompile it. If you have the source code and have built it, you usually could compile it with DWARF debug information (e.g. adding -g to some CFLAGS in a Makefile...) and run it under gdb

Notice that even on Linux you might have malware (e.g. for Debian or Ubuntu you might have found a .deb source which is used to publish malware; this is unlikely, but not impossible). Trusting a binary package provider is a social issue, not a technical one. Your installedBinary might (in principle) be bad enough to put you in trouble. But it is probably some executable.

Perhaps your installedBinary is always waiting for some input from its stdin (such a behavior might be unusual but is not forbidden) or from some other source. Then you might try installedBinary < /dev/null and even installedBinary --help < /dev/null

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • 2
    I'm curious what you expect to find in the documentation that would be helpful in this investigation. Or are you just suggesting using the documentation instead of using the `--help` option? – Barmar Sep 19 '18 at 18:51
  • I'm not sure "your command isn't doing anything? it might be malware!" is accurate or useful advice – that other guy Sep 19 '18 at 21:06
  • We don't *know* the source of the package. Some people might setup e.g. a `.deb` source somewhere (for Debian or Ubuntu) and publish malicious software thru that. It is unlikely, but not impossible. And *trusting* a `.deb` package provider is a social issue, not a technical one – Basile Starynkevitch Sep 20 '18 at 05:14