Merge lp:~alan-griffiths/compiz-core/Bug.833729 into lp:compiz-core

Proposed by Alan Griffiths
Status: Merged
Merged at revision: 3067
Proposed branch: lp:~alan-griffiths/compiz-core/Bug.833729
Merge into: lp:compiz-core
Diff against target: 71 lines (+34/-6)
1 file modified
plugins/composite/src/screen.cpp (+34/-6)
To merge this branch: bzr merge lp:~alan-griffiths/compiz-core/Bug.833729
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Review via email: mp+98872@code.launchpad.net

Commit message

If composite doesn't load exit the process instead of crashing later

Description of the change

If composite doesn't load, then very few plugins will work (and most will crash). So exit with a clue to help figure out the underlying problem.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I agree in advance that this is a horrible hack. But making the client code either handle errors, or exception neutral is a LOT of work. This could give us some more immediate feedback on the causes of failure.

Revision history for this message
Ɓukasz Zemczak (sil2100) wrote :

This is indeed a very hacky approach, but I understand that it's handle it gracefully. But I'm a bit reluctant about using a macro for this like it. It might be confusing later on if not explicitly noted in the comments that this is 'temporary'. Such code I would prefer not to include in compiz-core, but maybe as a distro patch? Or wouldn't it be possible overwrite the setFailed() method for CompositeScreen to do the exit() call and some debug printing? I know we would loose the neat _LINE_ thing, but such an approach would at least be more stylish. Still, even that wouldn't be the final solution IMO. Not sure about what could!

3070. By Alan Griffiths

Apology

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

Could you please add some more *critical* info to:

            compLogMessage ("composite", CompLogLevelError,
                            "Screen %d on display \"%s\" already "
                            "has a compositing manager; try using the "
                            "--replace option to replace the current "
                            "compositing manager.",
                            screen->screenNum (), DisplayString (dpy));

So that it also outputs the currentCmSnOwner printed in 0xhex format? Then we will at least know which is the offending window.

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

Also, I'm wondering how hard it would be to check and enforce plugin dependencies in core, so that core doesn't try to load any plugin that depends on one which has failed to load...

That would be better than merging this branch.

3071. By Alan Griffiths

More diagnositic information

3072. By Alan Griffiths

merge

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

Added requested diagnostic.

I don't see how we can fix plugin loading without an ABI change - too much indulgence in templates.

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

Agreed. Any nice fix will break the ABI. Let's keep this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/composite/src/screen.cpp'
2--- plugins/composite/src/screen.cpp 2012-02-09 06:57:51 +0000
3+++ plugins/composite/src/screen.cpp 2012-03-23 09:36:20 +0000
4@@ -45,6 +45,9 @@
5
6 #include <core/timer.h>
7
8+#include <cstdlib>
9+#include <cstdio>
10+
11 CompWindow *lastDamagedWindow = 0;
12
13 void
14@@ -195,6 +198,26 @@
15 return priv->damageEvent;
16 }
17
18+/* TODO - remove these macros, also <cstdio> and <cstdlib> above.
19+ *
20+ * We're seeing errors in code that tries to use composite after
21+ * it fails to initialise.
22+ *
23+ * I agree in advance that this macro subverting setFailed() is a
24+ * horrible hack. But making the client code either handle errors,
25+ * or exception neutral, is a LOT of work.
26+ *
27+ * This could give us some more immediate feedback on the causes
28+ * of failure and a better solution.
29+ * Alan Griffiths
30+ */
31+#define ARG_STRINGIZE(x) ARG_STRINGIZE_(x)
32+#define ARG_STRINGIZE_(x) #x
33+#define setFailed()\
34+do { \
35+ std::fputs("error CompositeScreen::CompositeScreen - line " ARG_STRINGIZE(__LINE__) "\n", stderr);\
36+ std::exit(EXIT_FAILURE);\
37+} while (false)
38
39 CompositeScreen::CompositeScreen (CompScreen *s) :
40 PluginClassHandler<CompositeScreen, CompScreen, COMPIZ_COMPOSITE_ABI> (s),
41@@ -257,6 +280,11 @@
42
43 }
44
45+#undef ARG_STRINGIZE
46+#undef ARG_STRINGIZE_
47+#undef setFailed
48+
49+
50 CompositeScreen::~CompositeScreen ()
51 {
52 priv->paintTimer.stop ();
53@@ -316,12 +344,12 @@
54 {
55 if (!replaceCurrentWm)
56 {
57- compLogMessage ("composite", CompLogLevelError,
58- "Screen %d on display \"%s\" already "
59- "has a compositing manager; try using the "
60- "--replace option to replace the current "
61- "compositing manager.",
62- screen->screenNum (), DisplayString (dpy));
63+ compLogMessage (
64+ "composite", CompLogLevelError,
65+ "Screen %d on display \"%s\" already has a compositing "
66+ "manager (%x); try using the --replace option to replace "
67+ "the current compositing manager.",
68+ screen->screenNum (), DisplayString (dpy), currentCmSnOwner);
69
70 return false;
71 }

Subscribers

People subscribed via source and target branches