Mir

Merge lp:~mzanetti/mir/dont-crash-when-shooting-invalid-surface into lp:mir

Proposed by Michael Zanetti
Status: Rejected
Rejected by: Alexandros Frantzis
Proposed branch: lp:~mzanetti/mir/dont-crash-when-shooting-invalid-surface
Merge into: lp:mir
Diff against target: 16 lines (+5/-1)
1 file modified
src/server/scene/application_session.cpp (+5/-1)
To merge this branch: bzr merge lp:~mzanetti/mir/dont-crash-when-shooting-invalid-surface
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Fixing
Kevin DuBois (community) Needs Fixing
PS Jenkins bot (community) continuous-integration Needs Fixing
Alan Griffiths Approve
Review via email: mp+207509@code.launchpad.net

Commit message

don't crash when we're trying to screenshot a non-existent surface.

This might happen when an app crashes and apport tracing it delays the applicationRemoved() for a couple of secs in which unity doesn't know the app is gone and might try to shoot it.

Description of the change

Proposed patch originally from Alexandros.

To post a comment you must log in.
1416. By Michael Zanetti

don't crash when we're trying to screenshot a non-existent surface.

This might happen when an app crashes and apport tracing it delays the applicationRemoved() for a couple of secs in which unity doesn't know the app is gone and might try to shoot it.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Would be nice to have a test. But OK for now.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

looks like the unit tests need updating:
[ FAILED ] ApplicationSession.uses_snapshot_strategy (91 ms)

would it be better to throw here, and catch somewhere in unity-mir?

I patched up a throwing version with a test: lp:~mir-team/mir/dont-crash-when-shooting-invalid-surface if you're interested

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I feel this syntax does not scale well:
   msh::Snapshot{{},{},nullptr}
It would probably be nicer to declare a const null_snapshot or something. But it's no big deal.

Kevin: I don't think throwing an exception is helpful. If the default_surface can be null under normal circumstances then I think take_snapshot should succeed transparently as in this proposal.

Also, there would seem to be a race between default_surface and take_snapshot_of. I'm assuming the only reason it's not racing is because surface is a shared_ptr.

Finally, I agree if the bug is simply crashing then it's a good candidate for an automated test case. But won't block on that. We should always welcome contributions from outside the team :)

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Oops.

[ RUN ] ApplicationSession.uses_snapshot_strategy
/tmp/buildd/mir-0.1.5+14.04.20140212/tests/unit-tests/scene/test_application_session.cpp:262: Failure
Actual function call count doesn't match EXPECT_CALL(*snapshot_strategy, take_snapshot_of(_,_))...
         Expected: to be called once
           Actual: never called - unsatisfied and active
unknown file: Failure
C++ exception with description "bad_function_call" thrown in the test body.
[ FAILED ] ApplicationSession.uses_snapshot_strategy (92 ms)

review: Needs Fixing
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Unmerged revisions

1416. By Michael Zanetti

don't crash when we're trying to screenshot a non-existent surface.

This might happen when an app crashes and apport tracing it delays the applicationRemoved() for a couple of secs in which unity doesn't know the app is gone and might try to shoot it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/scene/application_session.cpp'
2--- src/server/scene/application_session.cpp 2014-02-07 12:54:45 +0000
3+++ src/server/scene/application_session.cpp 2014-02-20 17:34:55 +0000
4@@ -99,7 +99,11 @@
5
6 void ms::ApplicationSession::take_snapshot(msh::SnapshotCallback const& snapshot_taken)
7 {
8- snapshot_strategy->take_snapshot_of(default_surface(), snapshot_taken);
9+ auto surface = default_surface();
10+ if (surface)
11+ snapshot_strategy->take_snapshot_of(surface, snapshot_taken);
12+ else
13+ snapshot_taken(msh::Snapshot{{},{},nullptr});
14 }
15
16 std::shared_ptr<msh::Surface> ms::ApplicationSession::default_surface() const

Subscribers

People subscribed via source and target branches