Possible to crash command-not-found if ctrl+c is sent really really early

Bug #977695 reported by Chris Tandiono
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
command-not-found
New
Undecided
Unassigned

Bug Description

It's possible to crash /usr/lib/command-not-found if a user presses ctrl+c before it imports "sys". This causes the exception handler to attempt to call "sys.exit(127)', but of course "sys" has not yet been imported. This kind of defeats the purpose of the KeyboardInterrupt exception handler and causes apport to start running, which it shouldn't, since there really isn't anything wrong.

Admittedly, it's hard to trigger this bug; I accidentally triggered it with the help of hdapsd to pause my hard disk while the first few imports are being made, but before "import sys" is run.

I've attached the patch which should resolve this issue. Whether it's particularly better than what we currently have isn't really clear. Perhaps "import sys" should be moved to before the try block.

Revision history for this message
Chris Tandiono (chris-tandiono) wrote :
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Thanks, I'll apply this

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

Other bug subscribers

Patches

Remote bug watches

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