Obsidian-StudiosInc / ecrire

General purpose graphical Text Editor built on the Enlightenment Foundation Libraries (EFL)
GNU General Public License v3.0
7 stars 1 forks source link

settings dialog segfault ecrire #49

Closed NuLogicSystems closed 4 years ago

NuLogicSystems commented 5 years ago

ecrire 0.3.4 on efl 1.23.0 crashes when trying to open settings. Segmentation fault (core dumped)

wltjr commented 5 years ago

Thank you for the report! Any chance of a backtrace with gdb or something I can use to look into this? I am not able to replicate, as of this moment.

wltjr commented 5 years ago

@NuLogicSystems any further information on this issue? Does it still exist with EFL 1.23.2?

NuLogicSystems commented 5 years ago

Can't get the docs for EFL 1.23.2 to build ATM. I'm not sure if its something they changed there, if the tarball is simply missing something, or if there is a bug in it, to cause it to error out, but I'm looking into it.

ApostolosB commented 5 years ago
#0  0x000055fdb2c0238c in ?? ()
#1  0x00007f2681d43453 in _item_select (it=0x55fdb4914030) at ../src/lib/elementary/elm_toolbar.c:1095
#2  0x00007f268105f769 in _edje_emit_cb (prop=0 '\000', data=<optimized out>, src=0x55fdb45f1740 "elm",
    sig=0x55fdb47f0abc "elm,action,click", ed=0x55fdb4914b90) at ../src/lib/edje/edje_program.c:1678
#3  _edje_emit_handle (ed=0x55fdb4914b90, sig=0x55fdb47f0abc "elm,action,click", src=0x55fdb45f1740 "elm", sdata=<optimized out>,
    prop=0 '\000') at ../src/lib/edje/edje_program.c:1593
#4  0x00007f26810599b1 in _edje_message_queue_process () at ../src/lib/edje/edje_message_queue.c:926
#5  0x00007f2681059b92 in _edje_message_queue_process () at ../src/lib/edje/edje_message_queue.c:895
#6  _edje_job (data=<optimized out>) at ../src/lib/edje/edje_message_queue.c:297
#7  0x00007f26819a7afb in _ecore_job_event_handler (data=<optimized out>, type=<optimized out>, ev=<optimized out>)
    at ../src/lib/ecore/ecore_job.c:95
#8  0x00007f26819ad0d9 in _ecore_event_message_handler_efl_loop_message_handler_message_call (obj=0x400000000d2e, pd=0x55fdb4108880,
    message=0x4000001eb128) at ../src/lib/ecore/ecore_event_message_handler.c:362
#9  0x00007f26819b5f13 in efl_loop_message_handler_message_call (obj=0x400000000d2e, message=0x4000001eb128)
    at src/lib/ecore/efl_loop_message_handler.eo.c:14
#10 0x00007f26819af1aa in _efl_loop_message_process (obj=<optimized out>, pd=0x55fdb4100e10) at ../src/lib/ecore/efl_loop.c:598
#11 0x00007f26819adfa1 in efl_loop_message_process (obj=obj@entry=0x40000000012b) at ../src/lib/ecore/efl_loop.c:636
#12 0x00007f26819a9daf in _ecore_main_loop_iterate_internal (obj=obj@entry=0x40000000012b, pd=pd@entry=0x55fdb4100e10,
    once_only=once_only@entry=0) at ../src/lib/ecore/ecore_main.c:2493
#13 0x00007f26819aa435 in _ecore_main_loop_begin (obj=obj@entry=0x40000000012b, pd=pd@entry=0x55fdb4100e10)
    at ../src/lib/ecore/ecore_main.c:1199
#14 0x00007f26819aefe6 in _efl_loop_begin (obj=0x40000000012b, pd=0x55fdb4100e10) at ../src/lib/ecore/efl_loop.c:57
#15 0x00007f26819ae261 in efl_loop_begin (obj=0x40000000012b) at src/lib/ecore/efl_loop.eo.c:28
#16 0x00007f26819aa4e9 in ecore_main_loop_begin () at ../src/lib/ecore/ecore_main.c:1284
#17 0x000055fdb2bff60b in elm_main ()
#18 0x000055fdb2bfd04f in ?? ()
#19 0x00007f268148c153 in __libc_start_main () from /usr/lib/libc.so.6
#20 0x000055fdb2bfd09e in _start ()
(gdb)

the backtrace of it.

wltjr commented 5 years ago

@NuLogicSystems thank you for the backtrace. I am still not able to replicate the crash. I have a few questions.

Does it crash as soon as you click settings?

Are you using settings from the drop down file menu, or from the toolbar?

Wayland or X11?

I may have a few more. I have tried from both drop down menu and toolbar, and from drop down menu with toolbar disabled. Unfortunately, no crashing for me. I am running X11, it maybe something related to Wayland if you are running that. I will see about testing under Wayland. Thanks again for the backtrace!

ApostolosB commented 5 years ago

From the Toolbar. Crashes instantly. And wayland.

NuLogicSystems commented 5 years ago

Both and both.

wltjr commented 5 years ago

@ApostolosB I assume it also crashes from drop down file menu. Also, thank you for the backtrace, gave credit to wrong person... :-1:

@NuLogicSystems are you referring to both X11 and Wayland? Or do you mean both toolbar and drop down file menu?

To both, any issues with Toolbars or Naviframes in elementary_test?

Thank you for the information. I am still unable to replicate the crash, thus all the questions. At the moment, I am also unable to run e under Wayland, or ecrire without e. Once I can run e or ecrire under wayland, hopefully, I will be able to replicate the crash. I am really curious where that is coming from, the toolbar, naviframe, wayland vs x11, etc. Thanks again for helping out!

NuLogicSystems commented 5 years ago

I mean both toolbar and drop down file menu as well as under both X11 and Wayland. I thought that was obvious, as I answered both questions in order as given. I did leave out the first question though. Yes, it crashes right after clicking on settings.

wltjr commented 5 years ago

@NuLogicSystems thank you and sorry for the redundancy. I am just trying to find someway I can replicate the issue to figure out why it is crashing.

ApostolosB commented 5 years ago

when running i from the command line you get

CRI<14385>:ecore_evas ../src/lib/elementary/efl_ui_win.c:8907 elm_win_resize_object_add() Use of this API is forbidden after calling an EO API on this window. Fix your code!
Segmentation fault (core dumped)

Might give a clue on the crash maybe??.

BTW it crashes on Weston also.

wltjr commented 4 years ago

@ApostolosB thanks, definitely something I need to change. I am unsure if that is the cause of the crash. Since the crash happens when opening the settings, and those lines are part of the main window. If it crashed on start, then it would make more sense to be from that function call. Maybe it is from the combo of those function calls plus the settings dialog that triggers the crash. Either way, I need to look into removing and/or replacing that function call per the output message.

Are you using any special env variables or invocation to get that or just doing ecrire in a terminal? I am not seeing that message, but I recall seeing it in something before. Thanks again for the follow-up information! Even if it is not the cause, I appreciate the effort in helping track down the source!

wltjr commented 4 years ago

@ApostolosB I see the message now, it is generated when you open the settings. I do not call that function outside the main file. You can grep the sources and see. I only use that function in main.c and it does not generate that message. I am looking into naviframe and else where in EFL widgets used in the settings dialog. You maybe onto something there, but I am not sure I can address the issue in ecrire code. I am still not able to replicate the crash, unfortunately. That would really help if I could get it to crash for me.

wltjr commented 4 years ago

Here is the line of code in ecrire that generates the fix your code message. Looks like it has something to do with win = elm_win_inwin_add (parent);

That very well maybe the cause of the crash, as it is the first part of code for the settings UI.

wltjr commented 4 years ago

I am still unable to replicate the crash. Although, I think I may know where the issue is coming from, the alpha aspect of the main window. I believe, that is where the EO stuff is involved. Why it only affects the inner window is beyond my current knowledge of EFL.

Try to comment out the following lines, main.c Line 1253-1254 and settings_dialog.c Line 82

Here is a diff to use as a patch if you prefer

diff --git a/src/bin/main.c b/src/bin/main.c
index be7e5be..77375de 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -1250,8 +1250,8 @@ create_window(int argc, char *argv[])
                                   (Evas_Object_Event_Cb)_win_move_cb,
                                   _win);

-   if(_ent_cfg->alpha)
-     ecrire_alpha_set(_ent_cfg->alpha);
+//   if(_ent_cfg->alpha)
+//     ecrire_alpha_set(_ent_cfg->alpha);

    if(_ent_cfg->height && _ent_cfg->width)
      evas_object_resize(_win, _ent_cfg->width, _ent_cfg->height);
diff --git a/src/bin/ui/settings_dialog.c b/src/bin/ui/settings_dialog.c
index 238cb31..7ab5943 100644
--- a/src/bin/ui/settings_dialog.c
+++ b/src/bin/ui/settings_dialog.c
@@ -79,7 +79,7 @@ _settings_alpha_cb (void *data EINA_UNUSED,
                    void *event_info EINA_UNUSED)
 {
   ent_cfg->alpha = elm_slider_value_get (obj);
-  ecrire_alpha_set(ent_cfg->alpha);
+//  ecrire_alpha_set(ent_cfg->alpha);
   ecrire_cfg_save();
 }

If someone could please apply that diff/patch or comment out those lines and see if it fixes the crash issue. That would really be helpful, thank you! When I comment out those lines, the error message on fixing your code goes away. Thus, I assume that is the cause of the crash/issue.

wltjr commented 4 years ago

Any news on this? I assume it is still crashing. @ApostolosB did you build ecrire with debugging symbols, when you did the GDB output in https://github.com/Obsidian-StudiosInc/ecrire/issues/49#issuecomment-551066649? It looks like only EFL was built with debugging symbols.

ApostolosB commented 4 years ago
#0  0x0000562b744203fc in _settings_font_list_get (e=<optimized out>) at /usr/src/debug/ecrire/src/bin/ui/settings_dialog.c:179
179     /usr/src/debug/ecrire/src/bin/ui/settings_dialog.c: No such file or directory.
[Current thread is 1 (Thread 0x7f53af091d40 (LWP 12865))]
/usr/lib/../share/gcc-9.2.0/python/libstdcxx/v6/xmethods.py:731: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
  refcounts = ['_M_refcount']['_M_pi']
(gdb) bt
#0  0x0000562b744203fc in _settings_font_list_get (e=<optimized out>) at /usr/src/debug/ecrire/src/bin/ui/settings_dialog.c:179
#1  _settings_dialog_font (_ent_cfg=<optimized out>, doc=0x562b7506c070, parent=0x40000033e7af) at /usr/src/debug/ecrire/src/bin/ui/settings_dialog.c:527
#2  ui_settings_dialog_open (parent=0x400000006a5c, doc=0x562b7506c070, _ent_cfg=<optimized out>) at /usr/src/debug/ecrire/src/bin/ui/settings_dialog.c:607
#3  0x00007f53b0fc9b23 in _item_select (it=0x562b75678210) at ../src/lib/elementary/elm_toolbar.c:1095
#4  0x00007f53b02e5769 in _edje_emit_cb (prop=0 '\000', data=<optimized out>, src=0x562b753210f0 "elm", sig=0x562b7554b44c "elm,action,click", ed=0x562b75678d70)
    at ../src/lib/edje/edje_program.c:1678
#5  _edje_emit_handle (ed=0x562b75678d70, sig=0x562b7554b44c "elm,action,click", src=0x562b753210f0 "elm", sdata=<optimized out>, prop=0 '\000')
    at ../src/lib/edje/edje_program.c:1593
#6  0x00007f53b02df9b1 in _edje_message_queue_process () at ../src/lib/edje/edje_message_queue.c:926
#7  0x00007f53b02dfb92 in _edje_message_queue_process () at ../src/lib/edje/edje_message_queue.c:895
#8  _edje_job (data=<optimized out>) at ../src/lib/edje/edje_message_queue.c:297
#9  0x00007f53b0c2dafb in _ecore_job_event_handler (data=<optimized out>, type=<optimized out>, ev=<optimized out>) at ../src/lib/ecore/ecore_job.c:95
#10 0x00007f53b0c330a9 in _ecore_event_message_handler_efl_loop_message_handler_message_call (obj=0x400000000e45, pd=0x562b74e3a870, message=0x40000033dbac)
    at ../src/lib/ecore/ecore_event_message_handler.c:362
#11 0x00007f53b0c3bed3 in efl_loop_message_handler_message_call (obj=0x400000000e45, message=0x40000033dbac) at src/lib/ecore/efl_loop_message_handler.eo.c:14
#12 0x00007f53b0c3517a in _efl_loop_message_process (obj=<optimized out>, pd=0x562b74e32e10) at ../src/lib/ecore/efl_loop.c:598
#13 0x00007f53b0c33f71 in efl_loop_message_process (obj=obj@entry=0x400000000242) at ../src/lib/ecore/efl_loop.c:636
#14 0x00007f53b0c2fd9c in _ecore_main_loop_iterate_internal (obj=obj@entry=0x400000000242, pd=pd@entry=0x562b74e32e10, once_only=once_only@entry=0)
    at ../src/lib/ecore/ecore_main.c:2493
#15 0x00007f53b0c30415 in _ecore_main_loop_begin (obj=obj@entry=0x400000000242, pd=pd@entry=0x562b74e32e10) at ../src/lib/ecore/ecore_main.c:1199
#16 0x00007f53b0c34fb6 in _efl_loop_begin (obj=0x400000000242, pd=0x562b74e32e10) at ../src/lib/ecore/efl_loop.c:57
#17 0x00007f53b0c34231 in efl_loop_begin (obj=0x400000000242) at src/lib/ecore/efl_loop.eo.c:28
#18 0x00007f53b0c304c9 in ecore_main_loop_begin () at ../src/lib/ecore/ecore_main.c:1284
#19 0x0000562b7441d67b in elm_main (argv=0x7ffd6ab6bb98, argc=1) at /usr/src/debug/ecrire/src/bin/main.c:1393
#20 elm_main (argc=1, argv=0x7ffd6ab6bb98) at /usr/src/debug/ecrire/src/bin/main.c:1337
#21 0x0000562b7441b04f in main (argc=1, argv=0x7ffd6ab6bb98) at /usr/src/debug/ecrire/src/bin/main.c:1403
(gdb)

Does this output help??? Just build git with debug. On stable E and EFL.

wltjr commented 4 years ago

@ApostolosB, thank you for that. It does not show the exact problem, but it does provide more information than the previous one. It looks to potentially be something with the font portion of settings. I wish I knew what was different on the systems where it crashes and mine, so, I could replicate the crash myself. Thanks again for the backtrace!

wltjr commented 4 years ago

@ApostolosB, actually, it looks like line 179 might be the problem. I do a null check on prev_font but not on efp or efp->name. If either efp or efp->name are null, that would explain the crash. I am assuming it is efp that is null, but it could be efp->name. See if this diff/patch makes a difference.

diff --git a/src/bin/ui/settings_dialog.c b/src/bin/ui/settings_dialog.c
index 238cb31..c02e70d 100644
--- a/src/bin/ui/settings_dialog.c
+++ b/src/bin/ui/settings_dialog.c
@@ -175,19 +175,25 @@ _settings_font_list_get(const Evas *e)
         Elm_Font_Properties *efp;

         efp = elm_font_properties_get(font);
-        /* Remove dups */
-        if (prev_font && !strcmp(efp->name, prev_font))
-          {
-             flist = eina_list_remove_list(flist, itr);
-          }
-        else
+
+        if(efp)
           {
-             eina_stringshare_replace(&font, efp->name);
-             prev_font = font;
-             eina_list_data_set(itr, font);
+            /* Remove dups */
+            if (prev_font &&
+                efp->name &&
+                !strcmp(efp->name, prev_font))
+              {
+                 flist = eina_list_remove_list(flist, itr);
+              }
+            else if (efp->name)
+              {
+                 eina_stringshare_replace(&font, efp->name);
+                 prev_font = font;
+                 eina_list_data_set(itr, font);
+              }
+
+            elm_font_properties_free(efp);
           }
-
-        elm_font_properties_free(efp);
      }

    return flist;

That does explain why I am not able to replicate. There is likely a specific font, missing from my systems, that is causing the issue.

ApostolosB commented 4 years ago

Works with the patch.

wltjr commented 4 years ago

Great, thanks for testing and the back trace! I will commit the changes and close this issue.