buggins / dlangui

Cross Platform GUI for D programming language
Boost Software License 1.0
804 stars 120 forks source link

"Console" platform outputs garbage into terminal #480

Closed denizzzka closed 6 years ago

denizzzka commented 6 years ago

After initial drawing of example1 it sends garbage symbols to terminal if I move mouse over terminal window.

Also, now we have some ncurses D libraries on code.dlang.org. Maybe it makes sense to remove direct esc-codes calls?

buggins commented 6 years ago

Are you running it under Linux?

denizzzka commented 6 years ago

Are you running it under Linux?

Yes

denizzzka commented 6 years ago

Reproducing: set (or resize while example1 runs) terminal window to size about ~152x54

buggins commented 6 years ago

Thanks. Let me try.

denizzzka commented 6 years ago

to size about ~152x54

more than*

buggins commented 6 years ago

Looks like program crashes (Program exited with code -11) and garbage is just mouse events displayed in terminal after program exited.

denizzzka commented 6 years ago

Huh! Confirmed. Backtrace:

$ gdb ./bin/example1 /tmp/core.example1.1507798810.1000.1000.5641
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bin/example1...done.
[New LWP 5641]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/e9/769e5d86c2f2a0652b38041f0e48334d95b570.debug]
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/d8/979dbb35017954507894a12aa70ce2ef0e9b49.debug]
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/f8/30cffc69d2fb86097c4776d397bf58cab2b8fb.debug]
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/ad/f51e0aeadeab97be8477c04b75c4be44c3fc03.debug]
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/93/c123cbc9d19f47fb995008fb2c55f0689fea8c.debug]
Core was generated by `./bin/example1'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00005613e7907758 in dlangui.core.types.__T3RefTC7dlangui8graphics9resources8DrawableZ.Ref.clear() (this=...) at ../../src/dlangui/core/types.d:490
490             _data.releaseRef();
(gdb) bt
#0  0x00005613e7907758 in dlangui.core.types.__T3RefTC7dlangui8graphics9resources8DrawableZ.Ref.clear() (this=...) at ../../src/dlangui/core/types.d:490
#1  0x00005613e7842d68 in dlangui.widgets.controls.ImageWidget.__dtor() (this=0x7f3a9540ec00) at ../../src/dlangui/widgets/controls.d:230
#2  0x00005613e7843621 in dlangui.widgets.controls.ImageWidget.__aggrDtor() (this=0x7f3a9540ec00) at ../../src/dlangui/widgets/controls.d:229
#3  0x00005613e799571f in rt_finalize2 ()
#4  0x00005613e7969d86 in rt_finalize ()
#5  0x00005613e77c195c in object.__T7destroyTC7dlangui7widgets6widget6WidgetZ.destroy() (obj=0x7f3a9540ec00) at /usr/include/dmd/druntime/import/object.d:2735
#6  0x00005613e78ada9f in dlangui.core.collections.__T10ObjectListTC7dlangui7widgets6widget6WidgetZ.ObjectList.clear() (this=..., destroyObj=true) at ../../src/dlangui/core/collections.d:331
#7  0x00005613e78adc4f in dlangui.core.collections.__T10ObjectListTC7dlangui7widgets6widget6WidgetZ.ObjectList.__dtor() (this=...) at ../../src/dlangui/core/collections.d:355
#8  0x00005613e7897eac in dlangui.widgets.widget.WidgetGroup.__fieldDtor() (this=0x7f3a9540ea00) at ../../src/dlangui/widgets/widget.d:1721
#9  0x00005613e799571f in rt_finalize2 ()
#10 0x00005613e7995816 in rt_finalizeFromGC ()
#11 0x00005613e79903de in gc.impl.conservative.gc.Gcx.sweep() ()
#12 0x00005613e7990d2d in gc.impl.conservative.gc.Gcx.fullcollect() ()
#13 0x00005613e7993472 in gc.impl.conservative.gc.ConservativeGC.__T9runLockedS107_D2gc4impl12conservative2gc14ConservativeGC18fullCollectNoStackMFNbZ2goFNbPS2gc4impl12conservative2gc3GcxZmTPS2gc4impl12conservative2gc3GcxZ.runLocked() ()
#14 0x00005613e798d439 in gc.impl.conservative.gc.ConservativeGC.fullCollectNoStack() ()
#15 0x00005613e798d40a in gc.impl.conservative.gc.ConservativeGC.collectNoStack() ()
#16 0x00005613e79afc05 in gc_term ()
#17 0x00005613e7994937 in rt_term ()
#18 0x00005613e7967f02 in rt.dmain2._d_run_main() ()
#19 0x00005613e7967e74 in rt.dmain2._d_run_main() ()
#20 0x00005613e7967de4 in _d_run_main ()
#21 0x00005613e77e4ed2 in main ()
(gdb)
buggins commented 6 years ago

It crashes on GC collecting resources. I see "UIAppMain returned 0" in ui.log - and then crash on attempt to GC. Looks like root cause is in exiting of UIAppMain unexpectedly w/o freeing resources.

buggins commented 6 years ago

added some debug logs - now I see

rawWrite error 11 - stopping terminal

enum EAGAIN             = 11;       /// Try again
buggins commented 6 years ago

Probably fixed. Could you please confirm.

denizzzka commented 6 years ago

Works! Thanks!

denizzzka commented 6 years ago

Small issue again: after ctrl+C example1 immediately exits and after it console again displays garbage if mouse moves.

IMHO, dlangui is need to capture ctrl+C signal and prepare terminal to exit.

denizzzka commented 6 years ago

I just can not decide who should do that: application code (example1) or dlangui itself. Some text user interface programs should not to be breakable by ctrl+c.

buggins commented 6 years ago

It should be fixed in dlangui

buggins commented 6 years ago

fixed

denizzzka commented 6 years ago

Confirmed