Access violation in Lazarus IDE when sparta_DockedFormEditor is installed and a unit with a frame is closed
Original Reporter info from Mantis: JuhaManninen @JuhaManninen
-
Reporter name: Juha Manninen
Original Reporter info from Mantis: JuhaManninen @JuhaManninen
- Reporter name: Juha Manninen
Description:
Closing a unit with a Form seems to work.
Without sparta_DockedFormEditor there is no access violation.
For testing you must build Lazarus with debug flags on. I built it with: -gw -gl -godwarfsets -gh -gt -Co -Cr -Ci -Sa
I have tested on Linux with GTK2 and KDE5 bindings. It does not look like widgetset dependent.
I suppose the bug is related to the automatic memory management of interfaced objects like TFrameDesignerForm.
They get somehow wrongly freed. Such errors are nasty to debug and find.
Removing these lines:
- if LookupRoot is TControl then
- TControl(LookupRoot).RemoveAllHandlersOfObject(Self);
from destructor TFrameDesignerForm.Destroy changes the error. Then with GTK2 bindings I get:
The program 'lazarus' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
(Details: serial 286340 error_code 3 request_code 12 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
Steps to reproduce:
Install sparta_DockedFormEditor into Lazarus (AnchorDocking is not needed).
Using any existing GUI application project, open unit sparta_BasicResizeFrame from package sparta_MDI.
Close the newly opened sparta_BasicResizeFrame --> CRASH.
Additional information:
Debug lines and a debugger backtrace:
TDesigner.PrepareFreeDesigner: TheFormEditor=TFormEditor, Designer=TDesigner
TNonFormProxyDesignerForm.Destroy: Self=_Designer_BasicResizeFrame:TFrameProxyDesignerForm, LookupRoot=nil
Thread 1 "lazarus" received signal SIGSEGV, Segmentation fault.
0x0000000000432285 in fpc_do_is ()
(gdb) bt
#0 0x0000000000432285 in fpc_do_is ()
#1 0x0000000000000003 in ()
#2 0x000000000059c53d in DBGSNAME (P=0xf0f0f0f0f0f0f0f0) at LazLoggerImpl.inc:410
#3 0x000000000059fbbb in ARGSTOSTRING (this=0x7ffff59bd400, ARGS=..., highARGS=3) at lazloggerbase.pas:778
#4 0x00000000005a08ac in DEBUGLN (this=0x7ffff59bd400, ARGS=..., highARGS=3) at lazloggerbase.pas:919
#5 0x000000000049e63d in DEBUGLN (ARGS=..., highARGS=3) at lclproc.pas:1336
#6 0x000000000129c305 in DESTROY (this=0x7fffd32a5ac0, vmt=0x1) at ../designer/framedesigner.pas:68
#7 0x000000000043390f in SYSTEM$_$TINTERFACEDOBJECT_$__$$__RELEASE$$LONGINT ()
#8 0x0000000000000001 in ()
#9 0x00007fffd32a5b10 in ()
#10 0x00007fffffffcc28 in ()
#11 0x0000000000432316 in fpc_intf_decr_ref ()
#12 0x00007ffff4da6370 in ()
#13 0x0000000000b704f0 in DELETECOMPONENT (this=0x7fffec9bc3c0, ACOMPONENT=0x7fffd8169cb0, FREECOMPONENT=true) at customformeditor.pp:646
#14 0x0000000000b5b7dd in PREPAREFREEDESIGNER (this=0x7fffd8171150, AFREECOMPONENT=true) at ../designer/designer.pp:829
#15 0x0000000000ec4b45 in CLOSEUNITCOMPONENT (ANUNITINFO=0x7fffec44b7f0, FLAGS=...) at sourcefilemanager.pas:7191
#16 0x0000000000eaca62 in CLOSEEDITORFILE (AEDITOR=0x7fffec6065c0, FLAGS=...) at sourcefilemanager.pas:2697
#17 0x00000000004c9729 in DOCLOSEEDITORFILE (this=0x7ffff4c802f0, AEDITOR=0x7fffec6065c0, FLAGS=...) at main.pp:5880
#18 0x00000000004bbc74 in MNUCLOSECLICKED (this=0x7ffff4c802f0, SENDER=0x7fffd35106b0) at main.pp:3400
#19 0x00000000004bbeee in SRCNOTEBOOKFILECLOSE (this=0x7ffff4c802f0, SENDER=0x7fffd35106b0, ACLOSEOPTIONS=...) at main.pp:3439
#20 0x0000000000ca4055 in CLOSECLICKED (this=0x7fffec43f430, SENDER=0x7fffd35106b0, CLOSEOPTIONS=...) at sourceeditor.pp:8418
#21 0x0000000000ca3e7f in CLOSETABCLICKED (this=0x7fffec43f430, SENDER=0x7fffd35106b0) at sourceeditor.pp:8379
#22 0x0000000000677028 in DOCLOSETABCLICKED (this=0x7fffec4413b0, APAGE=0x7fffd35106b0) at include/customnotebook.inc:455
#23 0x0000000000711061 in GTKNOTEBOOKCLOSEBTNCLICKED (WIDGET=0x2df5330, DATA=0x7fffd35106b0) at gtk2/gtk2callback.inc:134
#24 0x00007ffff74cfcaa in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#25 0x00007ffff74bd706 in () at /usr/lib/libgobject-2.0.so.0
#26 0x00007ffff74c189a in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#27 0x00007ffff74c2700 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#28 0x00007ffff7582895 in () at /usr/lib/libgtk-x11-2.0.so.0
#29 0x00007ffff74cfcaa in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#30 0x00007ffff74bd854 in () at /usr/lib/libgobject-2.0.so.0
#31 0x00007ffff74c189a in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#32 0x00007ffff74c2700 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#33 0x00007ffff75817ba in () at /usr/lib/libgtk-x11-2.0.so.0
#34 0x00007ffff762a7cc in () at /usr/lib/libgtk-x11-2.0.so.0
#35 0x00007ffff74cfcaa in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#36 0x00007ffff74bcf78 in () at /usr/lib/libgobject-2.0.so.0
#37 0x00007ffff74c0e2c in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#38 0x00007ffff74c2700 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#39 0x00007ffff7745235 in () at /usr/lib/libgtk-x11-2.0.so.0
#40 0x00007ffff7628a0e in gtk_propagate_event () at /usr/lib/libgtk-x11-2.0.so.0
#41 0x00007ffff7628e43 in gtk_main_do_event () at /usr/lib/libgtk-x11-2.0.so.0
#42 0x00007ffff7cf8d5e in () at /usr/lib/libgdk-x11-2.0.so.0
#43 0x00007ffff73e4cf4 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#44 0x00007ffff73e6b11 in () at /usr/lib/libglib-2.0.so.0
#45 0x00007ffff73e6b51 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#46 0x000000000050fcd1 in APPWAITMESSAGE (this=0x7ffff7f8f3f0) at gtk2/gtk2widgetset.inc:2433
#47 0x000000000048fdb4 in IDLE (this=0x7ffff7f8ec90, WAIT=true) at include/application.inc:414