Bug 42676 - Mono segfaults trying to look up keycode for Mod4/Super/'Windows' key
Summary: Mono segfaults trying to look up keycode for Mod4/Super/'Windows' key
Status: RESOLVED DUPLICATE of bug 41505
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: 4.4.0 (C7)
Hardware: PC Linux
: --- normal
Target Milestone: Community
Assignee: Bugzilla
Depends on:
Reported: 2016-07-19 20:03 UTC by ginjaninja32
Modified: 2016-07-20 00:55 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description ginjaninja32 2016-07-19 20:03:22 UTC
Found and tested on Mono 4.4.1 (Nightly Thu Jul 14 18:06:32 UTC 2016), running on Arch Linux x64 with i3 as window manager.

Example program (based on a Googled tutorial) - I've not used C# or Mono before, but in trying to narrow it down I found that the program occasionally prints "Could not set X locale modifiers" at startup, and does *not* segfault when Mod4 is pressed - this isn't dependent on separate compiles, the same executable executed multiple times may show both behaviours.

using System.Windows.Forms;

public class Program {
    public static void Main() {
        Application.Run(new Form());
run with `mcs test.cs -r:System.Windows.Forms.dll && mono test.exe`, then press the Mod4/Super/'Windows' key while the resulting blank window is focused.

stderr including stack trace:


  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Windows.Forms.X11Leopard.Xutf8LookupString (intptr,System.Windows.Forms.XEvent&,byte[],int,intptr&,System.Windows.Forms.XLookupStatus&) <0x000a4>
  at System.Windows.Forms.X11Keyboard.LookupString (System.Windows.Forms.XEvent&,int,System.Windows.Forms.XKeySym&,System.Windows.Forms.XLookupStatus&) <0x000c3>
  at System.Windows.Forms.X11Keyboard.EventToVkey (System.Windows.Forms.XEvent) <0x0003f>
  at System.Windows.Forms.X11Keyboard.ToUnicode (int,int,string&) <0x0035f>
  at System.Windows.Forms.X11Keyboard.TranslateMessage (System.Windows.Forms.MSG&) <0x00127>
  at System.Windows.Forms.XplatUIX11.TranslateMessage (System.Windows.Forms.MSG&) <0x00023>
  at System.Windows.Forms.XplatUI.TranslateMessage (System.Windows.Forms.MSG&) <0x0001f>
  at System.Windows.Forms.Application.RunLoop (bool,System.Windows.Forms.ApplicationContext) <0x00cf7>
  at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext) <0x00057>
  at System.Windows.Forms.Application.Run (System.Windows.Forms.Form) <0x00033>
  at Program.Main () <0x0003f>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0x000ba>

Native stacktrace:

	mono() [0x4acddf]
	mono() [0x500dce]
	mono() [0x428a43]
	/usr/lib/libpthread.so.0(+0x10f00) [0x7f30b092ff00]
	/usr/lib/libc.so.6(strlen+0x26) [0x7f30b03e5d76]
	/usr/lib/libX11.so.6(_XimLocalUtf8LookupString+0xeb) [0x7f30ac0f3b1b]

Debug info from gdb:

[New LWP 2850]
[New LWP 2851]
warning: File "/usr/bin/mono-sgen-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
	add-auto-load-safe-path /usr/bin/mono-sgen-gdb.py
line to your configuration file "/home/nyx/.gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/home/nyx/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
0x00007f30b092fb5b in waitpid () from /usr/lib/libpthread.so.0
  Id   Target Id         Frame 
* 1    Thread 0x7f30b1437780 (LWP 2849) "mono" 0x00007f30b092fb5b in waitpid () from /usr/lib/libpthread.so.0
  2    Thread 0x7f30afbff700 (LWP 2850) "mono" 0x00007f30b092c0af in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  3    Thread 0x7f30b0213700 (LWP 2851) "Finalizer" 0x00007f30b092e497 in do_futex_wait.constprop () from /usr/lib/libpthread.so.0

Thread 3 (Thread 0x7f30b0213700 (LWP 2851)):
#0  0x00007f30b092e497 in do_futex_wait.constprop () from /usr/lib/libpthread.so.0
#1  0x00007f30b092e544 in __new_sem_wait_slow.constprop.0 () from /usr/lib/libpthread.so.0
#2  0x00000000005b7d57 in ?? ()
#3  0x0000000000597dd1 in ?? ()
#4  0x0000000000648a6a in ?? ()
#5  0x00007f30b0926484 in start_thread () from /usr/lib/libpthread.so.0
#6  0x00007f30b044f6dd in clone () from /usr/lib/libc.so.6

Thread 2 (Thread 0x7f30afbff700 (LWP 2850)):
#0  0x00007f30b092c0af in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x0000000000617283 in ?? ()
#2  0x00007f30b0926484 in start_thread () from /usr/lib/libpthread.so.0
#3  0x00007f30b044f6dd in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7f30b1437780 (LWP 2849)):
#0  0x00007f30b092fb5b in waitpid () from /usr/lib/libpthread.so.0
#1  0x00000000004aceb6 in ?? ()
#2  0x0000000000500dce in ?? ()
#3  0x0000000000428a43 in ?? ()
#4  <signal handler called>
#5  0x00007f30b03e5d76 in strlen () from /usr/lib/libc.so.6
#6  0x00007f30ac0f3b1b in _XimLocalUtf8LookupString () from /usr/lib/libX11.so.6
#7  0x00000000404cd425 in ?? ()
#8  0x0000000000000000 in ?? ()

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
Comment 1 Rodrigo Kumpera 2016-07-20 00:33:46 UTC

While we aim to fix all bugs in mono, WinForms is not a library we actively maintain anymore. On the other hand, we encourage the community to submit fixes for such issues through a pull request on github repository.
Comment 2 Rodrigo Kumpera 2016-07-20 00:55:51 UTC
This looks like a dupe of #41505

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