Subject: Remove bindings core dump and a proposal fix

From: Olivier Chapuis <[email-masked]>
Date: Mon, 20 Mar 2000 07:38:06 +0100

Hello,

I've got a core dump if I do:

- Start fvwm without config file
- open FvwmConsole
- Read the file "test" which is attached to this message
  *2 times*
- execute FuncFvwmRemoveBindings

=> core dump !

I've no direct fix to this core dump, the fix is maybe obvious 
but I do not see the problems. However, I propose the following
that fix the core dump and which add bindings in a more
intelligent way (I hope):

------------------------------------------------------------
--- bindings.c.orig     Mon Mar 20 06:37:10 2000
+++ bindings.c  Mon Mar 20 06:56:49 2000
@@ -202,9 +202,8 @@
     action++;
 
   /*
-  ** is this an unbind request?
+  ** Remove the "old" bindings if any
   */
-  if (!action || action[0] == '-')
   {
     Bool is_binding_removed = False;
     Binding *b;
@@ -254,8 +253,11 @@
        *nr_right_buttons = 0;
       update_nr_buttons(bcontexts, nr_left_buttons, nr_right_buttons);
     }
-    return 0;
   }
+
+  /* return if it is an unbind request */
+  if (!action || action[0] == '-') return 0;
+
   update_nr_buttons(contexts, nr_left_buttons, nr_right_buttons);
 
   if((mods & AnyModifier)&&(mods&(~AnyModifier)))
-----------------------------------------------------------------------

I.e., I suggest that before adding a bindings we remove the old one
if any. In my opinion this is a fix because if not, it seems that
bindings are added and added and added ... (as with Style before 
Dominik change the way to merge styles).
I do not commit this "fix" because I do not really understand the
above core dump and maybe this may break some config (but I do not
think so ...).
So comments or/and two votes for such a commit and no objection is 
welcome.

Olivier

# pointer in Root
Mouse 3 	R	A	Menu MenuFvwmWindowOps
Mouse 3 	TSF	A	Menu MenuFvwmWindowOps2
Mouse 3 	W	M	Menu MenuFvwmWindowOps
Mouse 3 	I	A	Menu MenuFvwmWindowOps2
Mouse 3 	I	S	FuncFvwmIconifySameResource toggle

DestroyFunc FuncFvwmRemoveBindings
AddToFunc   FuncFvwmRemoveBindings
+ I Mouse 3 	R	A	-
+ I Mouse 3 	TSF	A	-
+ I Mouse 3 	W	M	-
+ I Mouse 3 	I	A	-
+ I Mouse 3 	I	S	-

---

From: Mikhael Goikhman <[email-masked]>
Date: Tue, 21 Mar 2000 04:42:15 +0200

> intelligent way (I hope):

Seems like this is a right patch fixing memory leaks.

Do you have the stack of the core? From the code, everything should be
allocated twice and then freed twice, I also can't see problems.

Regards,
Mikhael.
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Olivier Chapuis <[email-masked]>
Date: Tue, 21 Mar 2000 11:59:59 +0100

> allocated twice and then freed twice, I also can't see problems.

Here:
[olivier@snoopy olivier]$ gdb fvwm2 core
GNU gdb 4.17
Core was generated by `fvwm2'.
Program terminated with signal 11, Erreur de segmentation..
find_solib: Can't read pathname for load map: Erreur d'entrée/sortie.

#0  ParseBinding (dpy=0x80909d0, pblist=0x808fdfc, 
    tline=0x80a4cfe "3 \tI\tS\t-", type=0 '\000', nr_left_buttons=0x8090764, 
    nr_right_buttons=0x8090768, buttons_grabbed=0x8090788 "\a", 
    do_ungrab_root=0) at bindings.c:215
215           tmp = b->NextBinding;
(gdb) where
#0  ParseBinding (dpy=0x80909d0, pblist=0x808fdfc, 
    tline=0x80a4cfe "3 \tI\tS\t-", type=0 '\000', nr_left_buttons=0x8090764, 
    nr_right_buttons=0x8090768, buttons_grabbed=0x8090788 "\a", 
    do_ungrab_root=0) at bindings.c:215
#1  0x807ea2d in binding_cmd (eventp=0x808f680, w=38, tmp_win=0x0, context=8, 
    action=0x80a4cfe "3 \tI\tS\t-", Module=0xbffff100, type=0, do_grab_root=0)
    at bindings.c:323
#2  0x807eabe in mouse_binding (eventp=0x808f680, w=38, tmp_win=0x0, 
    context=8, action=0x80a4cfe "3 \tI\tS\t-", Module=0xbffff100)
    at bindings.c:344
#3  0x8071c85 in ExecuteFunction (Action=0x80a2d90 "Mouse 3 \tI\tS\t-", 
    tmp_win=0x0, eventp=0x808f680, context=8, Module=-2, 
    expand_cmd=EXPAND_COMMAND) at functions.c:858
#4  0x8072494 in execute_complex_function (eventp=0x808f680, w=0, tmp_win=0x0, 
    context=8, action=0x80a4c40 "FuncFvwmRemoveBindings\n", Module=0xbffff26c, 
    desperate=0xbffff220, expand_cmd=DONT_EXPAND_COMMAND) at functions.c:1334
#5  0x8071cb7 in ExecuteFunction (
    Action=0xbffff2a0 "FuncFvwmRemoveBindings\n", tmp_win=0x0, 
    eventp=0x808f680, context=8, Module=0, expand_cmd=EXPAND_COMMAND)
    at functions.c:864
#6  0x806fedb in HandleModuleInput (w=0, channel=0, expect=0x0)
    at module_interface.c:614
#7  0x8064f1a in My_XNextEvent (dpy=0x80909d0, event=0x808f680)
#8  0x80623fb in HandleEvents () at events.c:248
#9  0x8068947 in main (argc=1, argv=0xbffffbd4) at fvwm.c:711