After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 780285 - mutter crashes when no primary display is available
mutter crashes when no primary display is available
Status: RESOLVED DUPLICATE of bug 730551
Product: mutter
Classification: Core
Component: general
3.23.x
Other Linux
: Normal critical
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2017-03-20 00:55 UTC by Igor Ingultsov
Modified: 2017-04-12 07:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
check whether primary logical monitor is available (1.01 KB, patch)
2017-03-20 00:59 UTC, Igor Ingultsov
needs-work Details | Review

Description Igor Ingultsov 2017-03-20 00:55:43 UTC
libmutter crashes, when no primary logical monitor is available, because of lack of checking for null pointer.
Comment 1 Igor Ingultsov 2017-03-20 00:59:27 UTC
Created attachment 348290 [details] [review]
check whether primary logical monitor is available

Check for null pointers and rather terminate properly,
instead of a segfault.
Comment 2 Jonas Ådahl 2017-03-20 01:37:57 UTC
Review of attachment 348290 [details] [review]:

::: src/backends/meta-backend.c
@@ +132,3 @@
+    {
+      meta_fatal("Unable to get primary logical monitor\n");
+    }

Does this happen on hotplug without any prior configuration, or is mutter deliberately configured to have no active outputs?

Either way, this should not be fatal. Instead, change the "meta_monitor_manager_is_headless()" to check "logical_monitors" instead of "monitors", to also include the case where the "headlessness" is a result of an explicit configuration, and not the physical state.
Comment 3 Igor Ingultsov 2017-03-20 02:25:22 UTC
At the moment this is fatal anyway, because if primary == nullptr, accessing it's members will cause segfault here (next line):
https://github.com/GNOME/mutter/blob/master/src/backends/meta-backend.c#L132

Regarding the problem itself:
This is not a headless mode and the crash happens during post_init with x11 backend when Xorg is started in the root-less mode with nvidia proprietary drivers. Apparently Xorg and/or nvidia driver fails to detect/report display properly (this is what I don't know exactly).

Anyway, the ticket is rather about proper handling of null pointers, so mutter exits cleanly.
Comment 4 Jonas Ådahl 2017-03-20 03:20:47 UTC
(In reply to Igor Ingultsov from comment #3)
> At the moment this is fatal anyway, because if primary == nullptr, accessing
> it's members will cause segfault here (next line):
> https://github.com/GNOME/mutter/blob/master/src/backends/meta-backend.c#L132

Right, but changing a crash to an abort is not right here, since we should handle this case better.

> 
> Regarding the problem itself:
> This is not a headless mode and the crash happens during post_init with x11
> backend when Xorg is started in the root-less mode with nvidia proprietary
> drivers. Apparently Xorg and/or nvidia driver fails to detect/report display
> properly (this is what I don't know exactly).
>

Could you check what it is that is reported? This crash *should* only be able to happen if Xorg reports that there are monitors connected, but none are activated. This could probably happen (by using xrandr directly for example) and should be handled. Changing meta_monitor_manager_is_headless() to check the logical monitors instead of monitors would fix this. Does that fix the issue?
Comment 5 Igor Ingultsov 2017-03-20 14:32:54 UTC
> Right, but changing a crash to an abort is not right here, since we should handle this case better.
I don't see how fixing of logic is related to the null poitner check. It is still possible, that this pointer could be null, then it has to be checked.

Also I don't see how meta_monitor_manager_is_headless is related, because center_pointer is getting called from here in my case:
https://github.com/GNOME/mutter/blob/master/src/backends/meta-backend.c#L362
and NOT from here:
https://github.com/GNOME/mutter/blob/master/src/backends/meta-backend.c#L153
Comment 6 Jonas Ådahl 2017-03-20 14:47:03 UTC
(In reply to Igor Ingultsov from comment #5)
> > Right, but changing a crash to an abort is not right here, since we should handle this case better.
> I don't see how fixing of logic is related to the null poitner check. It is
> still possible, that this pointer could be null, then it has to be checked.
> 
> Also I don't see how meta_monitor_manager_is_headless is related, because
> center_pointer is getting called from here in my case:
> https://github.com/GNOME/mutter/blob/master/src/backends/meta-backend.c#L362
> and NOT from here:
> https://github.com/GNOME/mutter/blob/master/src/backends/meta-backend.c#L153

Ah, I see, sorry about that. I guess the easiest thing would be to just if (!primary) return; after getting the primary in center_pointer().
Comment 7 Igor Ingultsov 2017-03-20 16:01:09 UTC
It does not make sense to work around this problem here (even though I've tried). Because then gnome-shell crashes a little bit later in other place, because there are not logical monitors:

  • #0 meta_screen_get_monitor_index_for_rect
  • #1 ffi_call_unix64
  • #2 ffi_call
  • #3 0x00007ffa472c39ef in
  • #4 0x00007ffa472c50a4 in

I'd rather add also another check in meta_backend_real_post_init somewhere before calling center_pointer, to check for logical monitors and if there are none, mutter can't continue and should fail.
Comment 8 Jonas Ådahl 2017-04-12 07:33:03 UTC
Marking as duplicate of bug 730551. See the patches attached there.

*** This bug has been marked as a duplicate of bug 730551 ***