Page MenuHomePhabricator

efl-mono: Crash on focus callback when quitting focus example
Closed, InvalidPublic

Description

The C# Focus example prints a backtrace when the Quit button is pressed.

There is an event handler registered for focus events on the Quit button:

public static void FocusChangedCb(object sender, EventArgs e)                                     
{                                                                                                 
    Console.WriteLine($"Focus for object {((efl.IText)sender).GetText()} changed to {((efl.ui.IWidget)sender).GetFocus()}");                                                                            
}

This handler gets called when the app is quitting (to indicate that the button is losing focus, I guess). But when the event handler tries to retrieve the event sender's name it crashes with a NullReferenceException:

ERR<123485>:mono /home/xartigas/repos/efl-bindings/src/lib/elementary/efl_ui_button.eo.cs:2741 on_Efl_Ui_Focus_Object_FocusChangedEvt_NativeCallback() System.NullReferenceException: Object reference not set to an instance of an object
  at efl.ui.Button.On_Efl_Ui_Focus_Object_FocusChangedEvt (efl.ui.focus.Object+FocusChangedEvt_Args e) [0x00000] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
  at efl.ui.Button.on_Efl_Ui_Focus_Object_FocusChangedEvt_NativeCallback (System.IntPtr data, efl.Event& evt) [0x0001c] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
ERR<123485>:mono /home/xartigas/repos/efl-bindings/src/lib/elementary/efl_ui_button.eo.cs:2741 on_Efl_Ui_Focus_Object_FocusChangedEvt_NativeCallback() efl.EflException: Managed Code Error
  at eina.Error.Raise (eina.Error e) [0x00016] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
  at eina.Error.RaiseIfOccurred () [0x0000b] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
  at efl.ui.Button.GetText () [0x0000c] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
  at Example.FocusChangedCb (System.Object sender, System.EventArgs e) [0x0000c] in <98fff559a4dd4328998449f3ca971198>:0 
  at efl.ui.Button.On_Efl_Ui_Focus_Object_FocusChangedEvt (efl.ui.focus.Object+FocusChangedEvt_Args e) [0x0002d] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
  at efl.ui.Button.on_Efl_Ui_Focus_Object_FocusChangedEvt_NativeCallback (System.IntPtr data, efl.Event& evt) [0x0001c] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
ERR<123485>:mono /home/xartigas/repos/efl-bindings/src/lib/elementary/efl_ui_button.eo.cs:2741 on_Efl_Ui_Focus_Object_FocusChangedEvt_NativeCallback() efl.EflException: Managed Code Error
  at eina.Error.Raise (eina.Error e) [0x00016] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
  at eina.Error.RaiseIfOccurred () [0x0000b] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
  at efl.ui.Button.GetText () [0x0000c] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
  at Example.FocusChangedCb (System.Object sender, System.EventArgs e) [0x0000c] in <98fff559a4dd4328998449f3ca971198>:0 
  at efl.ui.Button.On_Efl_Ui_Focus_Object_FocusChangedEvt (efl.ui.focus.Object+FocusChangedEvt_Args e) [0x0002d] in <caf45713f1dd434f8d9efa39a45c76b2>:0 
  at efl.ui.Button.on_Efl_Ui_Focus_Object_FocusChangedEvt_NativeCallback (System.IntPtr data, efl.Event& evt) [0x0001c] in <caf45713f1dd434f8d9efa39a45c76b2>:0

This does not seem to happen in the C version, so I am assuming this is a bindings problem. I add @bu5hm4n as a subscriber, though, because he knows focus.

segfaultxavi triaged this task as TODO priority.

To me this looks like a problem with the get text call :)

vitor.sousa added a comment.EditedSep 18 2018, 11:27 AM

For me both C and C# versions are segfaulting when the Quit button is pressed.
But I also get

ERR<28729>:mono /home/vitorsousa/ework/efl/src/lib/elementary/efl_ui_button.eo.cs:2741 on_Efl_Ui_Focus_Object_FocusChangedEvt_NativeCallback() System.NullReferenceException: Object reference not set to an instance of an object
  at efl.ui.Button.On_Efl_Ui_Focus_Object_FocusChangedEvt (efl.ui.focus.Object+FocusChangedEvt_Args e) [0x00000] in <3bc2f8761b2a46b4b805d22f6618107e>:0 
  at efl.ui.Button.on_Efl_Ui_Focus_Object_FocusChangedEvt_NativeCallback (System.IntPtr data, efl.Event& evt) [0x0001c] in <3bc2f8761b2a46b4b805d22f6618107e>:0

just before the crash (in C# only).

And many of these before the NullReferenceException:

ERR<28729>:eo lib/eo/eo.c:1888 efl_unref() Eo ID 0x40000003c486 is not a valid object. Current thread: 0x7f5475fc8700. This ID has probably been deleted or this was never a valid object ID. (domain=0, current_domain=2, local_domain=2, available_domains=[  1 2  ], generation=86, id=
f1, ref=1)
## Copy & Paste the below (until EOF) into a terminal, then hit Enter

eina_btlog << EOF
/home/vitorsousa/einstall/lib/libeina.so.1       0x7f54709e542c 0x7f54709bc000
/home/vitorsousa/einstall/lib/libeina.so.1       0x7f54709e6151 0x7f54709bc000
/home/vitorsousa/einstall/lib/libeina.so.1       0x7f54709e7523 0x7f54709bc000
/home/vitorsousa/einstall/lib/libeo.so.1         0x7f5470579979 0x7f547056a000
/home/vitorsousa/einstall/lib/libeo.so.1         0x7f5470576029 0x7f547056a000
??       -
EOF

Is it the same of you @lauromoura ?

woohyun added a subscriber: woohyun.EditedJan 15 2019, 5:50 PM

@lauromoura @vitor.sousa

Today, I can get following errors when push "quit" button.
(of course, you need some changes on the example codes to avoid build errors)
(I executed the sample with "mono")

[Error Logs]

Eo instance right after internal_start 0x400000006b94 with refcount 1
Parent was 0x0
Eo instance right after internal_start 0x400000026c16 with refcount 2
Parent was 0x70368744205204
Eo instance right after internal_start 0x400000027c1a with refcount 2
Parent was 0x70368744336406
Eo instance right after internal_start 0x40000002e835 with refcount 2
Parent was 0x70368744336406
Eo instance right after internal_start 0x40000003504f with refcount 2
Parent was 0x70368744336406
Eo instance right after internal_start 0x40000003b869 with refcount 2
Parent was 0x70368744336406
Eo instance right after internal_start 0x400000042083 with refcount 2
Parent was 0x70368744336406
Eo instance right after internal_start 0x40000004889d with refcount 2
Parent was 0x70368744336406
Eo instance right after internal_start 0x4000000494a0 with refcount 2
Parent was 0x70368744474781
Eo instance right after internal_start 0x40000004ecb6 with refcount 2
Parent was 0x70368744474781
Focus for object Focus mover changed to True
Focus for object Focus mover changed to False
Focus for object Quit changed to True
Clicked Quit
ERR<27579>:eo lib/eo/eo.c:1913 efl_unref() Eo ID 0x40000003504f is not a valid object. Current thread: 0x7f462cf15700. This ID has probably been deleted or this was never a valid object ID. (domain=0, current_domain=2, local_domain=2, available_domains=[ 1 2 ], generation=4f, id=d4, ref=1)
ERR<27579>:eo lib/eo/eo.c:1913 efl_unref() Eo ID 0x40000003b869 is not a valid object. Current thread: 0x7f462cf15700. This ID has probably been deleted or this was never a valid object ID. (domain=0, current_domain=2, local_domain=2, available_domains=[ 1 2 ], generation=69, id=ee, ref=1)
ERR<27579>:eo lib/eo/eo.c:1913 efl_unref() Eo ID 0x4000000494a0 is not a valid object. Current thread: 0x7f462cf15700. This ID has probably been deleted or this was never a valid object ID. (domain=0, current_domain=2, local_domain=2, available_domains=[ 1 2 ], generation=a0, id=125, ref=1)
ERR<27579>:eo lib/eo/eo.c:1913 efl_unref() Eo ID 0x40000002e835 is not a valid object. Current thread: 0x7f462cf15700. This ID has probably been deleted or this was never a valid object ID. (domain=0, current_domain=2, local_domain=2, available_domains=[ 1 2 ], generation=35, id=ba, ref=1)
ERR<27579>:eo lib/eo/eo.c:1913 efl_unref() Eo ID 0x40000004ecb6 is not a valid object. Current thread: 0x7f462cf15700. This ID has probably been deleted or this was never a valid object ID. (domain=0, current_domain=2, local_domain=2, available_domains=[ 1 2 ], generation=b6, id=13b, ref=1)
ERR<27579>:mono /home/woohyun/EFL/efl/src/lib/elementary/efl_ui_widget.eo.cs:961 on_FocusChangedEvt_NativeCallback() System.NullReferenceException: Object reference not set to an instance of an object

at Efl.Ui.Widget.On_FocusChangedEvt (Efl.Ui.Focus.ObjectFocusChangedEvt_Args e) <0x418e82f0 + 0x00027> in <filename unknown>:0 
at Efl.Ui.Widget.on_FocusChangedEvt_NativeCallback (IntPtr data, Efl.Event_StructInternal& evt) <0x418e81a0 + 0x0007f> in <filename unknown>:0

Unhandled Exception:
System.ExecutionEngineException: SIGILL

at (wrapper managed-to-native) Efl.UnsafeNativeMethods:elm_shutdown ()
at Efl.Ui.Config.Shutdown () <0x418e9310 + 0x0000b> in <filename unknown>:0 
at Efl.All.Shutdown () <0x418e8eb0 + 0x0002f> in <filename unknown>:0 
at Example.Main () <0x418d81c0 + 0x00617> in <filename unknown>:0

[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException: SIGILL

at (wrapper managed-to-native) Efl.UnsafeNativeMethods:elm_shutdown ()
at Efl.Ui.Config.Shutdown () <0x418e9310 + 0x0000b> in <filename unknown>:0 
at Efl.All.Shutdown () <0x418e8eb0 + 0x0002f> in <filename unknown>:0 
at Example.Main () <0x418d81c0 + 0x00617> in <filename unknown>:0

This is still happening to me in 2019!

It only happens for me in the C# version, no in the C version. But at least I got a bit of a backtrace:

#0  0x00000000400378cb in  ()
#1  0x00007ffff1b36cb7 in efl_canvas_group_need_recalculate_set () at /usr/local/lib/x86_64-linux-gnu/libevas.so.1
#2  0x00007ffff2efb270 in  () at /usr/local/lib/x86_64-linux-gnu/libelementary.so
#3  0x00007ffff60007f0 in  ()
#4  0x00007fffffffc0e0 in  ()
#5  0x00007ffff31add40 in _EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED () at /usr/local/lib/x86_64-linux-gnu/libelementary.so
#6  0x0000000000000000 in  ()

Also, I built the example with MonoDevelop instead of mcs and I cannot make it fail :/

lauromoura raised the priority of this task from TODO to High.Mar 15 2019, 7:36 AM
brunobelo added a comment.EditedSep 16 2019, 6:10 AM

@segfaultxavi Is this error still happening today? i couldn't reproduce the error with current build.

segfaultxavi closed this task as Invalid.Sep 16 2019, 6:35 AM

I cannot repro it either. Nice!