red / red

Red is a next-generation programming language strongly inspired by Rebol, but with a broader field of usage thanks to its native-code compiler, from system programming to high-level scripting and cross-platform reactive GUI, while providing modern support for concurrency, all in a zero-install, zero-config, single ~1MB file!
http://red-lang.org
Boost Software License 1.0
5.54k stars 410 forks source link

[View] Hard CRASH with stack overflows when drawing rich-text #5139

Open hiiamboris opened 2 years ago

hiiamboris commented 2 years ago

Describe the bug

Title.

To reproduce

Run this in --cli mode (GUI just hangs silently):

Red []

r: rtd-layout ["abc"]
view [
    box rate 99 on-time [
        loop 999 [face/draw: compose [text 0x0 (copy/deep r)]]
    ]
]

After ~1 second it rapidly streams things like:

*** Internal Error: stack overflow
*** Where: reduce
*** Near : self word
*** Stack: view do-events do-actor do-safe error? show do-actor do-safe error? s
r? show do-actor do-safe error? show do-actor do-safe error? show do-actor do-sa
o-safe error? show do-actor do-safe error? show do-actor do-safe error? show do-
 do-actor do-safe error? show do-actor do-safe error? show do-actor do-safe erro
error? show do-actor do-safe error? show do-actor do-safe error? show do-actor d
or do-safe error? show do-actor do-safe error? show do-actor do-safe error? show
show do-actor do-safe error? show do-actor do-safe error? show do-actor do-safe
*** Internal Error: stack overflow
*** Where: do
*** Near : handler face event
*** Stack: view do-events do-actor do-safe error? show do-actor do-safe error? s
r? show do-actor do-safe error? show do-actor do-safe error? show do-actor do-sa
o-safe error? show do-actor do-safe error? show do-actor do-safe error? show do-
 do-actor do-safe error? show do-actor do-safe error? show do-actor do-safe erro
error? show do-actor do-safe error? show do-actor do-safe error? show do-actor d
or do-safe error? show do-actor do-safe error? show do-actor do-safe error? show
show do-actor do-safe error? show do-actor do-safe error? show do-actor do-safe

If you manage to close the window before it stack-overflows, you get:

*** Runtime Error 95: no CATCH for THROW
*** in file: common.reds
*** at line: 282
***
***   stack: ***-uncaught-exception
***   stack: ***-uncaught-exception
***   stack: ***-uncaught-exception

Expected behavior

No errors

Platform version

Red 0.6.4 for Windows built 15-May-2022/2:37:39+03:00  commit #2b72c44
hiiamboris commented 2 years ago

Linking this to other no cat for throw issues: https://github.com/red/red/issues/4990#issuecomment-957477940

qtxie commented 2 years ago

No error if just copy r.

qtxie commented 2 years ago

I think it's caused by OS resources cannot be freed by the GC. A weird workaround:

r: rtd-layout ["abc"]
view [
    box rate 99 on-time [
        loop 999 [face/draw: compose [text 0x0 (r)]]
        loop 999 [face/draw: compose [text 0x0 (copy/deep r)]]
    ]
]
hiiamboris commented 2 years ago

No problems with this:

Red []
view [
    box rate 99 on-time [
        loop 999 [face/draw: compose [text 0x0 (rtd-layout ["abc"])]]
    ]
]

so it's unlikely related to resources.