John Levon wrote: >On Sat, Dec 08, 2001 at 01:18:55PM +1100, Ben Stanley wrote: > >>I think I'm getting heap corruption... >> Well, I've carried out some testing using mpatrol, a big and thorough memory debugging library. It turns out that we are accessing heap memory after freeing it:
(Note that 0x55555555 is the value used to fill freed memory. I also set the mpatrol options so that freed memory is not immediately re-used.) FREE: free (0x55555555) [-|-|-] 0x40090423 fl_freepup+183 0x0824B59D for_each__H2ZPiZPFi_v_X01X01X11_X11+33 0x0819C9E6 MenuCallback__Q27Menubar5PimplP7flobjs_l+722 0x08199C84 C_Menubar_Pimpl_MenuCallback+20 0x4005B8BF fl_object_qread+127 0x40069B79 fl_check_forms+21 0x08159B11 runTime__10GUIRunTime+29 0x080A58C5 runTime__6LyXGUI+25 0x080A6020 __3LyXPiPPc+1660 0x080C4145 main+349 0x4103B0EE __libc_start_main+142 0x08054341 _start+33 ERROR: [NOTALL]: free: 0x55555555 has not been allocated FREE: free (0x55555555) [-|-|-] 0x40090453 fl_freepup+231 0x0824B59D for_each__H2ZPiZPFi_v_X01X01X11_X11+33 0x0819C9E6 MenuCallback__Q27Menubar5PimplP7flobjs_l+722 0x08199C84 C_Menubar_Pimpl_MenuCallback+20 0x4005B8BF fl_object_qread+127 0x40069B79 fl_check_forms+21 0x08159B11 runTime__10GUIRunTime+29 0x080A58C5 runTime__6LyXGUI+25 0x080A6020 __3LyXPiPPc+1660 0x080C4145 main+349 0x4103B0EE __libc_start_main+142 0x08054341 _start+33 ERROR: [NOTALL]: free: 0x55555555 has not been allocated FREE: free (0x08626348) [-|-|-] 0x4009047E fl_freepup+274 0x0824B59D for_each__H2ZPiZPFi_v_X01X01X11_X11+33 0x0819C9E6 MenuCallback__Q27Menubar5PimplP7flobjs_l+722 0x08199C84 C_Menubar_Pimpl_MenuCallback+20 0x4005B8BF fl_object_qread+127 0x40069B79 fl_check_forms+21 0x08159B11 runTime__10GUIRunTime+29 0x080A58C5 runTime__6LyXGUI+25 0x080A6020 __3LyXPiPPc+1660 0x080C4145 main+349 0x4103B0EE __libc_start_main+142 0x08054341 _start+33 ERROR: [PRVFRD]: free: 0x08626348 was freed with free 0x08626348 (32 bytes) {free:2717722:0} [-|-|-] 0x4009047E fl_freepup+274 0x0824B59D for_each__H2ZPiZPFi_v_X01X01X11_X11+33 0x0819C9E6 MenuCallback__Q27Menubar5PimplP7flobjs_l+722 0x08199C84 C_Menubar_Pimpl_MenuCallback+20 0x4005B8BF fl_object_qread+127 0x40069B79 fl_check_forms+21 0x08159B11 runTime__10GUIRunTime+29 0x080A58C5 runTime__6LyXGUI+25 0x080A6020 __3LyXPiPPc+1660 0x080C4145 main+349 0x4103B0EE __libc_start_main+142 0x08054341 _start+33 So we are freeing stuff twice... yuck. I poked around in Menubar_pimpl.C a little bit, but I don't know XForms... I could do with some help. I have a theory that we are freeing things in the wrong order, or trying to free child menus after freeing the parents (which maybe already freed the child menus?). Now, for those of you who run out of RAM while using electric fence, you might find some of this useful. mpatrol is a debugging library, and is not very efficient in it's memory usage (similarly to ef). Hence I have created extra swap space and added it to my system without rebooting: 1) Create swapfile: dd if=/dev/zero of=/swapfile bs=1024 count=524288 2) initialise swapfile: mkswap /swapfile 3) start using swapfile swapon /swapfile 4) check available memory: free The instructions above create a 0.5Gb swapfile. Change the count argument to get it bigger or smaller. When you have finished with the swapfile, use swapoff. Swapfiles installed in this way do not re-mount when you re-boot. You have to use swapon manually. I have found that I needed 2Gb swap to use mpatrol with LyX and my thesis... I'm on irc.openprojects.net/#lyx for a little while... Ben.