command-not-found crash on CTRL+C exit

Bug #146864 reported by ikehack
60
This bug affects 7 people
Affects Status Importance Assigned to Milestone
command-not-found
Fix Released
Low
rubens
command-not-found (Ubuntu)
Fix Released
Medium
rubens

Bug Description

Binary package hint: command-not-found

(on) From Ctrl+C interrupt. Kaboom, follow instructions, etc. Here's the error:

OS: Ubuntu Gusty Gibbion 7.10 BETA
Crash: from using Ctrl+C

No module named CommandNotFound
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 10, in <module>
    from CommandNotFound import CommandNotFound
ImportError: No module named CommandNotFound
Python version: 2.5.1 final 0

Nothing to do with the Ctrl+C method of exiting a command, but hey, it happened.

-Mike.

ikehack (ikehack)
description: updated
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for your bugreport.

Could you please describe the steps to reproduce this issue.

Thanks,
 mIchael

Changed in command-not-found:
status: New → Incomplete
Revision history for this message
ikehack (ikehack) wrote :

I did "ls -l" and it wasn't bashing out anything in the directory, it was just hanging there. I got impatient and CTRL+C'd about 3 times, then I got the command-not-found kaboom. Last time I checked "ls -l" is a real command. I hope that was some help to what you were looking for.

-Mike

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

It's a python issue.

As far as I know there is no way around it in *any* python program. That's why I wanted to write a C client. This is not fixable without patching python.

Revision history for this message
John Drinkwater (johndrinkwater) wrote :

Have just come across the same issue when typing in the wrong command and ctrl-Cing. Would be nice to see the bug accepted/confirmed.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

This is indeed a bug. It's annoying. I don't know any way to fix it though. It should remain open as a reminder.

Changed in command-not-found:
importance: Undecided → Medium
status: Incomplete → Confirmed
Revision history for this message
Marnen Laibow-Koser (marnen) wrote :

Yup, got it too:

KABOOOM!!!

Whoops, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/ubuntu/+source/command-not-found
Please include the following information with the report:
No module named CommandNotFound
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 10, in <module>
    from CommandNotFound import CommandNotFound
ImportError: No module named CommandNotFound
Python version: 2.5.1 final 0

This is on Gutsy.

Revision history for this message
ikehack (ikehack) wrote :

@ Marren,

Was that on the Ctrl-C method of exit?

Revision history for this message
Michael Vogt (mvo) wrote :

Hm, I can not reproduce this. Running "ls -lR /" and then hitting ctrl-c a couple of times make command-not-found not crash for me on hardy. Same for typing in something bogus command and then hitting ctrl-c quickly.

If someone can still reproduce it, could you please add some steps here?

Thanks,
 Michael

Changed in command-not-found:
status: Confirmed → Incomplete
Revision history for this message
Barthax (peterm-woodfordcomputers) wrote :

On Gutsy, I've just replicated the symptoms using the (mis-typed) command "sud su" - obviously sud was meant to be sudo. :)

The CLI had a think about it, I realised my mistake & hit CTRL+C to receive:

KABOOOM!!!

Whoops, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/ubuntu/+source/command-not-found
Please include the following information with the report:
No module named CommandNotFound
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 10, in <module>
    from CommandNotFound import CommandNotFound
ImportError: No module named CommandNotFound
Python version: 2.5.1 final 0

This can be reproduced at will if you leave a short moment before hitting CTRL+C after Return... It is often accompanied by the pre-symptom:

'import site' failed; use -v for traceback

Note that if you do have problems replicating, try adding a heavy CPU load to your machine & then issue.

Revision history for this message
Simon Déziel (sdeziel) wrote :

Same here :

KABOOOM!!!

Whoops, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/ubuntu/+source/command-not-found
Please include the following information with the report:
No module named CommandNotFound
 Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 10, in <module>
    from CommandNotFound import CommandNotFound
ImportError: No module named CommandNotFound
Python version: 2.5.1 final 0

After a CTRL+C

Revision history for this message
Garibaldi (garibaldi) wrote :

I have this same issue, however the situation was a bit different. I had a fresh install of an Ubuntu Gusty 7.10 variant (XFCE) and I simply shut down the computer (no errors or problems) and restart the machine. On restart, this message comes up and drops me to a root console. I cannot start X or the system. It is using ext3 but even so I thought I'd run fsck. After doing that, same problem

Revision history for this message
ikehack (ikehack) wrote :

Well, I've posted this bug quite a few months ago and there is no fix yet. What would be interesting if anyone has experienced this with the Ubuntu 4.08 RC (or by tomorrow the final release)

Revision history for this message
Garibaldi (garibaldi) wrote :

So would I just have to reinstall to fix it?

Revision history for this message
ikehack (ikehack) wrote :

@ Garibaldi

I don't think that would fix the problem.

Revision history for this message
Garibaldi (garibaldi) wrote :

@ikehack,

Is it some hardware related issue then?

Revision history for this message
Valentine Rozental (valentine-rozental) wrote :

I've just entered: "lls -tlr" instead of "ls -ltr" and at once hit CTRL+C

The result was similar like described in the thread begin:

$ lls -tlr
'import site' failed; use -v for traceback

KABOOOM!!!

Whoops, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/ubuntu/+source/command-not-found

valentine@atreides:~$ Please include the following information with the report:
No module named CommandNotFound
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 10, in <module>
    from CommandNotFound import CommandNotFound
ImportError: No module named CommandNotFound
Python version: 2.5.1 final 0

Revision history for this message
Dexo (interruptux) wrote :

$ EPS000004492 # I pasted random stuff in command line. Readcted with Ctrl+C. And then...

'import site' failed; use -v for traceback

KABOOOM!!!

Whoops, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/ubuntu/+source/command-not-found
Please include the following information with the report:
No module named CommandNotFound
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 10, in <module>
    from CommandNotFound import CommandNotFound
ImportError: No module named CommandNotFound
Python version: 2.5.1 final 0

Revision history for this message
ikehack (ikehack) wrote :

@ Garibaldi

In reference to your question about the bug being hardware related (sorry for the month delay) I really don't think it's hardware related. Given other people have been able to reproduce the problem as well as encounter it, it shouldn't be hardware. If it was, that would be one HELL of a problem. :)

Revision history for this message
cyzen (cyzen) wrote :

root@cyatom:/usr/share/doc/bash# while [ 1 ]; do "echo '2'" ;done
bash: echo '2': command not found
bash: echo '2': command not found
bash: echo '2': command not found
bash: echo '2': command not found
bash: echo '2': command not found
bash: echo '2': command not found
bash: echo '2': command not found
'import site' failed; use -v for traceback <======My CTRL-C

root@cyatom:/usr/share/doc/bash# Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/ubuntu/+source/command-not-found
Please include the following information with the report:
No module named CommandNotFound
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 10, in <module>
    from CommandNotFound import CommandNotFound
ImportError: No module named CommandNotFound
Python version: 2.5.2 final 0

Revision history for this message
ikehack (ikehack) wrote : Re: [Bug 146864] Re: command-not-found crash on CTRL+C exit

Over a year old, and no patch!

On Tue, Oct 21, 2008 at 7:13 PM, cyzen <email address hidden> wrote:
> root@cyatom:/usr/share/doc/bash# while [ 1 ]; do "echo '2'" ;done
> bash: echo '2': command not found
> bash: echo '2': command not found
> bash: echo '2': command not found
> bash: echo '2': command not found
> bash: echo '2': command not found
> bash: echo '2': command not found
> bash: echo '2': command not found
> 'import site' failed; use -v for traceback <======My CTRL-C
>
> root@cyatom:/usr/share/doc/bash# Sorry, command-not-found has crashed! Please file a bug report at:
> https://bugs.launchpad.net/ubuntu/+source/command-not-found
> Please include the following information with the report:
> No module named CommandNotFound
> Traceback (most recent call last):
> File "/usr/lib/command-not-found", line 10, in <module>
> from CommandNotFound import CommandNotFound
> ImportError: No module named CommandNotFound
> Python version: 2.5.2 final 0
>
> --
> command-not-found crash on CTRL+C exit
> https://bugs.launchpad.net/bugs/146864
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
ceka (geekcek) wrote :

The problem is still there; I misspelled 'gqview' and hit Ctrl-C quickly and got:

c@pagan:~/Desktop/Ce$ gqiew

c@pagan:~/Desktop/Ce$ 'import site' failed; use -v for traceback

KABOOOM!!!

Whoops, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/ubuntu/+source/command-not-found
Please include the following information with the report:
No module named CommandNotFound

c@pagan:~/Desktop/Ce$ Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 10, in <module>
    from CommandNotFound import CommandNotFound

c@pagan:~/Desktop/Ce$ ImportError: No module named CommandNotFound
Python version: 2.5.1 final 0

Revision history for this message
ikehack (ikehack) wrote :

Man, no fix. I'm going to brush up on my Python skills and try and
make a fix or do something with it :)

Michael Vogt (mvo)
Changed in command-not-found (Ubuntu):
status: Incomplete → Triaged
Revision history for this message
Michael Vogt (mvo) wrote :

The only proper fix for this (as Zygmunt Krynicki already pointed out) is to write a C client that can then catch SIGINT early. The problem with python is that during startup we can not install a SIGINT handler. So if ctrl-c is pressed early enough, a similar error is always going to show up (e.g. import site failed).

Revision history for this message
ikehack (ikehack) wrote :

A work around would be hard, or near impossible?

On Fri, Jun 26, 2009 at 4:13 AM, Michael Vogt<email address hidden> wrote:
> The only proper fix for this (as Zygmunt Krynicki already pointed out)
> is to write a C client that can then catch SIGINT early. The problem
> with python is that during startup we can not install a SIGINT handler.
> So if ctrl-c is pressed early enough, a similar error is always going to
> show up (e.g. import site failed).
>
> --
> command-not-found crash on CTRL+C exit
> https://bugs.launchpad.net/bugs/146864
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Zygmunt Krynicki (zyga)
Changed in command-not-found:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Ken Arnold (kenneth-arnold) wrote :

This is Python Issue 3137: http://bugs.python.org/issue3137

No activity in a year. You could poke around in http://svn.python.org/projects/python/trunk/Python/pythonrun.c. But be careful of an incomplete fix; this happens for other module imports also. e.g., I just got:

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 12, in <module>
    from optparse import OptionParser
  File "/usr/lib/python2.6/optparse.py", line 9, in <module>
    """
KeyboardInterrupt

Revision history for this message
kenorb (kenorb) wrote :

The same problem:

kenorb@NS8210H:~/websites/doc$ cd custom
kenorb@NS8210H:~/websites/doc/custom$ t
^C
kenorb@NS8210H:~/websites/doc/custom$ 'import site' failed; use -v for traceback

kenorb@NS8210H:~/websites/doc/custom$ cd wTraceback (most recent call last):
  File "/usr/lib/command-not-found", line 8, in <module>
    import CommandNotFound
ImportError: No module named CommandNotFound
at

Another:
kenorb@NS8210H:~/websites/doc/trunk/src/sites/all/modules/custom/wat$ Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 8, in <module>
    import CommandNotFound
ImportError: No module named CommandNotFound

Revision history for this message
Micheal Harker (mh0) wrote :

Thank you for reporting this bug to Ubuntu. Gusty reached EOL on April 18th, 2009.
Please see this document for currently supported Ubuntu releases:
https://wiki.ubuntu.com/Releases

Please feel free to report any other bugs you may find.

Changed in command-not-found (Ubuntu):
status: Triaged → Incomplete
Changed in command-not-found:
status: Confirmed → Incomplete
Revision history for this message
dotty (timdavies3) wrote :

This is very easily fixed by putting:
try:
   import ...
except ImportError:
   exit(..)

around the imports.

You can also use:

try:
   crash_guard(main, BUG_REPORT_URL, __version__)
except KeyboardInterrupt:
   pass

lower down to stop a Ctrl+C from creating tonnes of error messages.

I'd love to submit this as a patch however have no idea how to. If anyone would be interested in explaining how, or have some feedback on this fix, could you send me an email at <email address hidden>. Thanks.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

dotty, this cannot be fixed with python code. As explained in comment #25 this is a core python issue. Fortunately it seems to be fixed in python 2.6+ (I cannot reproduce this error any more so I'm going to close it)

Changed in command-not-found:
status: Incomplete → Fix Released
Changed in command-not-found (Ubuntu):
status: Incomplete → Fix Released
Revision history for this message
rubens (rubensdiasp) wrote :

versão de command-not-found: 0.3
Versão de Python: 3.4.0 final 0
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty
Informação de exceção:

'utf-8' codec can't encode character '\udc9b' in position 0: surrogates not allowed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 24, in crash_guard callback()
  File "/usr/lib/command-not-found", line 90, in main if not cnf.advise(args[0], options.ignore_installed) and not option.no_failure_msg:
  File "/usr/lib/python3/dist-packages/CommandNotFound.py, line 265 in advise packages = self.getPackages(command)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 157, in getPackages result.update([ db.component) for pkg in db. lookup(command)]
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 85, in lookup result = self.db.lookup(command)
  File "/usr/lib/python3/dist-pakages/CommandNotFound.py, line 41, in lookup key = key.encode('utf-8')
UnicodeEncodeError: 'utf-8' codec can't encode character '\udc9b' in position 0: surrogates not allowed

Changed in command-not-found:
assignee: nobody → rubens (rubensdiasp)
Changed in command-not-found (Ubuntu):
assignee: nobody → rubens (rubensdiasp)
Revision history for this message
Michael Novak (mykybo) wrote :

/mnt/c/repository$ q

^C
Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:

/mnt/c/repository$ command-not-found version: 0.3
Python version: 3.6.6 final 0
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
Exception information:

[Errno 3] No such process
Traceback (most recent call last):
  File "/usr/lib/python3.6/subprocess.py", line 405, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "/usr/lib/python3.6/subprocess.py", line 830, in communicate
    stdout = self.stdout.read()
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 23, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 90, in main
    if not cnf.advise(args[0], options.ignore_installed) and not options.no_failure_msg:
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 353, in advise
    snaps, mispell_snaps = self.get_snaps(command)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 113, in get_snaps
    universal_newlines=True)
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 412, in run
    process.kill()
  File "/usr/lib/python3.6/subprocess.py", line 1590, in kill
    self.send_signal(signal.SIGKILL)
  File "/usr/lib/python3.6/subprocess.py", line 1580, in send_signal
    os.kill(self.pid, sig)
ProcessLookupError: [Errno 3] No such process

Revision history for this message
Ethan (ethanwashere) wrote :

Michael, I don't know if this is the same issue as what opened the thread, but I got similar output to you after a Ctrl-C.

"foo"
^C
Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.6.9 final 0
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
Exception information:

[Errno 3] No such process
Traceback (most recent call last):
  File "/usr/lib/python3.6/subprocess.py", line 425, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "/usr/lib/python3.6/subprocess.py", line 855, in communicate
    self.wait()
  File "/usr/lib/python3.6/subprocess.py", line 1477, in wait
    (pid, sts) = self._try_wait(0)
  File "/usr/lib/python3.6/subprocess.py", line 1424, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 23, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 90, in main
    if not cnf.advise(args[0], options.ignore_installed) and not options.no_failure_msg:
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 353, in advise
    snaps, mispell_snaps = self.get_snaps(command)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 113, in get_snaps
    universal_newlines=True)
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 432, in run
    process.kill()
  File "/usr/lib/python3.6/subprocess.py", line 1610, in kill
    self.send_signal(signal.SIGKILL)
  File "/usr/lib/python3.6/subprocess.py", line 1600, in send_signal
    os.kill(self.pid, sig)
ProcessLookupError: [Errno 3] No such process

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.