Segmentation fault in meta_monitor_mode_get_resolution

Bug #1721718 reported by Michael Thayer
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
mutter (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

When I change the monitor configuration on my newly updated Artful system I get a desktop crash. A quick reproduction with gdb attached to gnome-shell gave the following back-trace, unfortunately with symbols for gnome-shell but not for libmutter (I am still a bit of a new-comer to gnome-shell).

Thread 1 "gnome-shell" received signal SIGSEGV, Segmentation fault.
0x00007f2b2d75bf50 in meta_monitor_mode_get_resolution ()
   from /usr/lib/x86_64-linux-gnu/libmutter-1.so.0
(gdb) bt
#0 0x00007f2b2d75bf50 in meta_monitor_mode_get_resolution ()
    at /usr/lib/x86_64-linux-gnu/libmutter-1.so.0
#1 0x00007f2b2d75bfd2 in meta_monitor_calculate_mode_scale ()
    at /usr/lib/x86_64-linux-gnu/libmutter-1.so.0
#2 0x00007f2b2d758437 in meta_finish_monitors_config_migration ()
    at /usr/lib/x86_64-linux-gnu/libmutter-1.so.0
#3 0x00007f2b2d7558fe in meta_monitor_config_manager_get_stored ()
    at /usr/lib/x86_64-linux-gnu/libmutter-1.so.0
#4 0x00007f2b2d75d732 in meta_monitor_manager_ensure_configured ()
    at /usr/lib/x86_64-linux-gnu/libmutter-1.so.0
#5 0x00007f2b2f531f9d in g_closure_invoke ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6 0x00007f2b2f544d5e in () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7 0x00007f2b2f54d535 in g_signal_emit_valist ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8 0x00007f2b2f54df4f in g_signal_emit ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9 0x00007f2b2f536464 in () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#10 0x00007f2b2f5388b9 in g_object_notify ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x00007f2b2f531f9d in g_closure_invoke ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x00007f2b2f544d5e in () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#13 0x00007f2b2f54d535 in g_signal_emit_valist ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#14 0x00007f2b2f54df4f in g_signal_emit ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#15 0x00007f2b2f536464 in () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#16 0x00007f2b2f5388b9 in g_object_notify ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#17 0x00007f2b23f1abbc in () at /usr/lib/x86_64-linux-gnu/libupower-glib.so.3
#18 0x00007f2b291bbe18 in ffi_call_unix64 ()
    at /usr/lib/x86_64-linux-gnu/libffi.so.6
#19 0x00007f2b291bb87a in ffi_call () at /usr/lib/x86_64-linux-gnu/libffi.so.6
#20 0x00007f2b2f532799 in g_cclosure_marshal_generic ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#21 0x00007f2b2f531f9d in g_closure_invoke ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#22 0x00007f2b2f5447d8 in () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#23 0x00007f2b2f54d535 in g_signal_emit_valist ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#24 0x00007f2b2f54df4f in g_signal_emit ()
    at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#25 0x00007f2b2f83f311 in () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#26 0x00007f2b2f82e804 in () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#27 0x00007f2b2f258de5 in g_main_context_dispatch ()
---Type <return> to continue, or q <return> to quit---
    at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#28 0x00007f2b2f2591b0 in () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#29 0x00007f2b2f2594c2 in g_main_loop_run ()
    at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#30 0x00007f2b2d79201c in meta_run ()
    at /usr/lib/x86_64-linux-gnu/libmutter-1.so.0
#31 0x000056266c5ff307 in main (argc=<optimized out>, argv=<optimized out>)
    at ../src/main.c:462

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: libmutter-1-0 3.26.0+20170925~ea214fb-1ubuntu1
ProcVersionSignature: Ubuntu 4.13.0-12.13-generic 4.13.3
Uname: Linux 4.13.0-12-generic x86_64
ApportVersion: 2.20.7-0ubuntu2
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Fri Oct 6 10:03:09 2017
InstallationDate: Installed on 2016-05-31 (492 days ago)
InstallationMedia: Ubuntu 15.10 "Wily Werewolf" - Release amd64 (20151021)
SourcePackage: mutter
UpgradeStatus: Upgraded to artful on 2017-10-05 (1 days ago)

Revision history for this message
Michael Thayer (michael-thayer) wrote :
Revision history for this message
Michael Thayer (michael-thayer) wrote :
Download full text (7.0 KiB)

Second try with debug symbols for glib2.0 and libmutter.

Thread 1 "gnome-shell" received signal SIGSEGV, Segmentation fault.
meta_monitor_mode_get_resolution (monitor_mode=monitor_mode@entry=0x0,
    width=width@entry=0x7fff256d5ad8, height=height@entry=0x7fff256d5adc)
    at backends/meta-monitor.c:1582
1582 backends/meta-monitor.c: Нет такого файла или каталога.
(gdb) bt
#0 0x00007f3df4941f50 in meta_monitor_mode_get_resolution (monitor_mode=monitor_mode@entry=0x0, width=width@entry=0x7fff256d5ad8, height=height@entry=0x7fff256d5adc) at backends/meta-monitor.c:1582
#1 0x00007f3df4941fd2 in calculate_scale (monitor_mode=0x0, monitor=0x55c462ebd040 [MetaMonitorNormal]) at backends/meta-monitor.c:1377
#2 0x00007f3df4941fd2 in meta_monitor_calculate_mode_scale (monitor=monitor@entry=0x55c462ebd040 [MetaMonitorNormal], monitor_mode=0x0)
    at backends/meta-monitor.c:1439
#3 0x00007f3df493e437 in meta_finish_monitors_config_migration (monitor_manager=monitor_manager@entry=0x55c462af81b0 [MetaMonitorManagerKms], config=config@entry=0x7f3dd0019750 [MetaMonitorsConfig], error=error@entry=0x7fff256d5b60)
    at backends/meta-monitor-config-migration.c:1177
#4 0x00007f3df493b8fe in meta_monitor_config_manager_get_stored (config_manager=0x7f3dd0005f20 [MetaMonitorConfigManager])
    at backends/meta-monitor-config-manager.c:385
#5 0x00007f3df4943732 in meta_monitor_manager_ensure_configured (manager=0x55c462af81b0 [MetaMonitorManagerKms]) at backends/meta-monitor-manager.c:487
#9 0x00007f3df6733f4f in <emit signal notify:lid-is-closed on instance 0x7f3dd000cb70 [UpClient]> (instance=instance@entry=0x7f3dd000cb70, signal_id=<optimized out>, detail=<optimized out>) at ../../../../gobject/gsignal.c:3447
    #6 0x00007f3df6717f9d in g_closure_invoke (closure=0x55c462ecde10, return_value=0x0, n_param_values=2, param_values=0x7fff256d5dc0, invocation_hint=0x7fff256d5d40) at ../../../../gobject/gclosure.c:804
---Type <return> to continue, or q <return> to quit---
    #7 0x00007f3df672ad5e in signal_emit_unlocked_R (node=node@entry=0x55c462ae0060, detail=detail@entry=302, instance=instance@entry=0x7f3dd000cb70, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fff256d5dc0) at ../../../../gobject/gsignal.c:3635
    #8 0x00007f3df6733535 in g_signal_emit_valist (instance=0x7f3dd000cb70, signal_id=<optimized out>, detail=302, var_args=var_args@entry=0x7fff256d5f90)
    at ../../../../gobject/gsignal.c:3391
#10 0x00007f3df671c464 in g_object_dispatch_properties_changed (object=0x7f3dd000cb70 [UpClient], n_pspecs=<optimized out>, pspecs=<optimized out>)
    at ../../../../gobject/gobject.c:1064
#11 0x00007f3df671e8b9 in g_object_notify_by_spec_internal (pspec=0x55c462b1c830 [GParamBoolean], object=0x7f3dd000cb70 [UpClient])
    at ../../../../gobject/gobject.c:1157
#12 0x00007f3df671e8b9 in g_object_notify (object=0x7f3dd000cb70 [UpClient], property_name=0x55c462ad20ff "lid-is-closed")
    at ../../../../gobject/gobject.c:1205
#16 0x00007f3df6733f4f in <emit signal notify:lid-is-closed on instance 0x55c462ae9580 [UpExportedDaemonProxy]> (instance=instance@entry=0x55c462ae9580, signal_id=<optimized out>, detail=...

Read more...

Revision history for this message
Michael Thayer (michael-thayer) wrote :

Quick fix below. For reasons of time I have done no testing beyond that GNOME Shell no longer crashes with the patch below. I have not tested the effect on scaling settings.

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

thanks for the bug/patch, two things:
1) the patch seems to be reversed :p
2) what about putting the if statement inside calculate_scale call?
static float
calculate_scale (MetaMonitor *monitor,
                 MetaMonitorMode *monitor_mode)
{
  int resolution_width, resolution_height;
  int width_mm, height_mm;
  int scale;

  scale = 1.0;
+ if (!monitor_mode)
+ goto out;
  meta_monitor_mode_get_resolution (monitor_mode,

this way the scale will be set to 1.0 in case monitor_mode is NULL.
(I followed the calls,
meta_monitor_calculate_mode_scale -> calculate_scale and this return of 1.0 in case of errors seems to be a safer solution, by just looking at the code.)

If Jeremy agrees, and you report he patch upstream, I think we can upload to artful.

I uploaded the "fix" (my version, I didn't test/check it for buildability) in my ppa
https://launchpad.net/~costamagnagianfranco/+archive/ubuntu/locutusofborg-ppa

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "mutter.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Michael Thayer (michael-thayer) wrote :

Gianfranco suggested off-Launchpad that I test the most recent version of libmutter (3.26.1), as it looks from the source as though this issue is fixed there. I will report back in a few days (I generally suspend and resume without restarting my session, so it will be a while until I start using the new library). Until then and unless I see otherwise let's assume that 3.26.1 fixes this.

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

oops, I din't notice the new mutter/vs the old one you tested.
http://launchpadlibrarian.net/339870376/mutter_3.26.0+20170925~ea214fb-1ubuntu1_3.26.1-1.diff.gz

+ if (!monitor_mode)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Mode not available on monitor");
+ return FALSE;
+ }

seems that somebody already did some similar code, so I presume the bug is already fixed in artful.

Changed in mutter (Ubuntu):
status: New → Incomplete
Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

there was a launchpad issue in posting this message, I now got it right

Revision history for this message
Michael Thayer (michael-thayer) wrote :

I overcame my laziness and restarted everything. I was just able to reconfigure monitors without a crash, so assume this is fixed. I can always re-open if really necessary. Thanks.

Changed in mutter (Ubuntu):
status: Incomplete → Fix Released
Revision history for this message
Michael Thayer (michael-thayer) wrote :

I saw something similar again today. Hard to say how similar. For some reason Apport does not seem to be doing the automatic reporting, though it looked like it was set up at a quick glance. I will try catching it myself.

Revision history for this message
Michael Thayer (michael-thayer) wrote :

Update: I see that there are files in /var/crash, but they are all from October 5. I will try deleting the GNOME Shell one and see if a new one is created if another crash happens.

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

Other bug subscribers

Remote bug watches

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