#1746 closed defect (fixed)

write test for anti-Ubuntu-crash-reporter exception-catching code

Reported by: ChosenOne Owned by: davidsarah
Priority: normal Milestone: 1.10.0
Component: code-frontend-cli Version: 1.9.1
Keywords: cli ubuntu apport usability error reviewed Cc:
Launchpad Bug:

Description

Hey,

I just noticed that 'tahoe put' (without any parameters, in an unconfigured state) might throw an IOError (No such file or directory: u'~/.tahoe/node.url').

While this itself is a little unfriendly towards user, it is also causing the Ubuntu 'Crash report' application the show up. The 'crash report' appears to be a new features in Ubuntu 12.04. Apparently, it's sitting in the background looking for failures/exceptions and nags people who know what they do :P

This may lead to bad statistics at Ubuntu about tahoe's stability. Also, it's pretty annoying. :)

(See attachment)

Attachments (2)

50.png (23.8 KB) - added by ChosenOne at 2012-05-20T14:25:01Z.
ubuntu crash report (collapsed)
fix-1746.darcs.patch (105.8 KB) - added by davidsarah at 2012-05-20T15:38:00Z.
Catch exceptions from CLI in order to prevent the Ubuntu crash monolog from triggering. refs #1746

Download all attachments as: .zip

Change History (22)

Changed at 2012-05-20T14:25:01Z by ChosenOne

ubuntu crash report (collapsed)

comment:1 Changed at 2012-05-20T14:40:30Z by ChosenOne

I have verified this with a fresh Ubuntu installation. The reporter is called "apport" and according to /etc/default/apport it is enabled by default now.

comment:2 Changed at 2012-05-20T14:47:07Z by davidsarah

  • Component changed from unknown to code-frontend-cli
  • Keywords apport usability error added; isability removed
  • Priority changed from normal to major

Grr, silly Ubuntu devs making our lives harder for no good reason.

"If you notice further problems, try restarting the computer."

What is this, Windows? As if restarting will help for 99% of conditions this detects :-(

comment:3 Changed at 2012-05-20T15:10:15Z by ChosenOne

See files in /etc/python*/sitecustomize.py:

# install the apport exception handler if available
try:
    import apport_python_hook
except ImportError:
    pass
else:
    apport_python_hook.install()

I traced it back into the apport-package, ubuntu provides. Installing the hook does the following

    sys.excepthook = apport_excepthook

This means that your python environment is modified like this:

print repr(sys.excepthook)
print sys.excepthook.func_name
print type(sys.excepthook)'
# <function apport_excepthook at 0x7fb84e5335f0>
# apport_excepthook
# <type 'function'>

A dirty, fix for this ticket could be (untested!)

import sys
import types # for comparison. can we do this better?
if types.FunctionType == type(sys.excepthook):
    if sys.excepthook.func_name == 'apport_excepthook':
        sys.excepthook = lambda *x: None
   

comment:4 Changed at 2012-05-20T15:28:26Z by davidsarah

Thanks ChosenOne for investigating this.

Knowing that it is implemented by sys.excepthook, we can easily prevent that from triggering, by catching exceptions at the entry point to the CLI.

Changed at 2012-05-20T15:38:00Z by davidsarah

Catch exceptions from CLI in order to prevent the Ubuntu crash monolog from triggering. refs #1746

comment:5 Changed at 2012-05-20T15:39:08Z by davidsarah

  • Keywords review-needed test-needed added
  • Milestone changed from undecided to soon
  • Owner changed from davidsarah to ChosenOne

ChosenOne?, please test this patch against trunk.

comment:6 Changed at 2012-05-20T18:24:14Z by ChosenOne

The exception remains, but apport is not started. Patch works.

comment:7 Changed at 2012-05-20T18:35:00Z by warner

I'm +1 for this for CLI commands like "tahoe put" and friends (although maybe we should just rewrite those commands to never report gateway failures or bad arguments as exceptions, always emitting a nicer error message).

I'm less confident about doing this for "tahoe start", if only for the case where we eventually have a double-clickable "launch tahoe" icon, and if the only way that an exception during startup can be noticed is by a GUI apport hook that notices the exception and reports it in a dialog (monolog) box.

I guess at a more fundamental level, Ubuntu (via apport) is telling us that exceptions are not an acceptable way to deliver "user made a mistake" error messages to users, which I can't entirely disagree with (although it's still pretty annoying).

comment:8 Changed at 2012-05-20T19:07:17Z by davidsarah

If we wanted to trap uncaught errors and display a modal dialog, we should do that. But I can't think why we would want it to look anything like the Ubuntu one, and I dislike intensely the idea that the error reporting behaviour of our code should be suddenly changed by distribution developers who obviously have no clue about usable error reporting should work.

In any case, this patch doesn't change the (visible) behaviour of tahoe start from what it does without apport.

Last edited at 2012-05-20T19:08:35Z by davidsarah (previous) (diff)

comment:9 Changed at 2012-05-20T19:12:08Z by gdt

In general, it seems a good rule is that python exceptions from CLI commands should only hit top-level and be user-perceptible if there is a code bug. Python backtraces are not really so different from "segementation violation -- core dumped".

comment:10 Changed at 2012-05-21T02:41:27Z by zooko

I agree with gdt.

Once we've fixed all such places in our code, so that we never intentionally display a Python backtrace to a user, then the behavior of the apport hook may not be inappropriate.

Any case where our code displays a Python backtrace to a user should be ticketed with the error keyword:

https://tahoe-lafs.org/trac/tahoe-lafs/query?status=!closed&keywords=~error&order=priority

comment:11 Changed at 2012-05-31T22:02:20Z by david-sarah@…

In 2ee1bc7148d45719:

(The changeset message doesn't reference this ticket)

comment:12 Changed at 2012-05-31T22:38:27Z by davidsarah

  • Milestone changed from soon to 1.10.0
  • Resolution set to fixed
  • Status changed from new to closed

This is fixed; please open another ticket or tickets for any inappropriate backtraces.

comment:13 Changed at 2012-05-31T23:11:00Z by davidsarah

  • Keywords review-needed removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening because it needs a test.

comment:14 Changed at 2012-06-01T20:36:45Z by warner

  • Priority changed from major to normal
  • Summary changed from IOError and verbose exceptions trigger Ubuntu crash reporter to write test for anti-Ubuntu-crash-reporter exception-catching code

updating title, priority

comment:15 Changed at 2012-06-01T20:37:43Z by warner

  • Owner changed from ChosenOne to davidsarah
  • Status changed from reopened to new

oh, also, ChosenOne's work is done here, assigning back to davidsarah for the test-writing

comment:16 Changed at 2012-07-16T16:33:56Z by david-sarah@…

In 5889/cloud-backend:

[rebased for cloud-backend] Catch exceptions from CLI in order to prevent the Ubuntu crash monolog from triggering. refs #1746

comment:17 Changed at 2013-01-03T03:22:50Z by davidsarah

  • Keywords review-needed added; test-needed removed
  • Owner changed from davidsarah to zooko

comment:18 Changed at 2013-01-31T16:13:53Z by amiller

  • Keywords reviewed added; review-needed removed

I've reviewed this patch and its test. The patch catches all exceptions in the CLI by having a try/catch around the 'run' function for all CLI commands. The test correctly distinguishes between when this exception is caught rather than propagated. I haven't directly checked that this solves the ubuntu app reporting problem, since I don't know how to build the ubuntu version. But ChosenOne?'s analysis about how catching the exception solves the problem makes sense.

comment:19 Changed at 2013-02-01T03:09:10Z by davidsarah

  • Owner changed from zooko to davidsarah
  • Status changed from new to assigned

comment:20 Changed at 2013-03-15T03:49:53Z by davidsarah

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in 52a583ce.

Note: See TracTickets for help on using tickets.