Skip to content

Instantly share code, notes, and snippets.

@hiiamboris
Created June 29, 2021 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiiamboris/731218353cc275c080e2633fca0e68e8 to your computer and use it in GitHub Desktop.
Save hiiamboris/731218353cc275c080e2633fca0e68e8 to your computer and use it in GitHub Desktop.
try/keep crasher
Red []
;--- IRRELEVANT CODE ---
;--- IF IT DOESN'T CRASH TRY DUPLICATING SOME OR REMOVING ----
assert: function [contract [block!]][
set/any [cond msg] reduce contract
unless :cond [
print ["ASSERTION FAILURE:" mold/part contract 100] ;-- limit the output in case we have face trees or images
if none? :msg [set/any 'msg last contract]
if any [any-word? :msg any-path? :msg] [
msg: either function? get/any msg
[ rejoin ["" msg " result is unexpected"] ]
[ rejoin ["" msg " is " mold/part/flat get/any msg 200] ]
]
do make error! form :msg
]
]
do/expand []
prettify: function [
"Reformat CODE with new-lines to look readable"
code [block! paren!] "Modified in place, deeply"
][
new-line/all from: code no ;-- start flat
until [
new-line code yes ;-- add newline before each independent expression
if error? try/all [code: preprocessor/fetch-next code] [code: next code]
tail? code
]
attempt [ ;-- in case it recurses into itself ;)
parse from [any [p:
set w ['print | 'prin] block! if (word? w) ;-- do not mistake words for lit-/get-words
| set w ['function | 'func | 'routine] if (word? w) ;-- do not mistake words for lit-/get-words
ahead block! ( ;-- special case for function spec (not very reliable detection :/ )
new-line/all p/2 no ;-- flatten the spec
unless empty? p/2 [new-line p/2 yes] ;-- expand the spec block
) into [any [p:
all-word! (new-line p yes) ;-- new-lines before argument/refinement names
opt [if (/local == p/1) to end] ;-- stop after /local
| skip
]]
| [block! | paren!] (
new-line p no ;-- disable new-line before block start
prettify p/1 ;-- prettify the inner block/paren
)
| skip
]]
]
from
]
;--- RELEVANT CODE
recycle/on
try [loop 9999 [try/keep [1 / 0]]]
try [loop 9999 [try/keep [1 / 0]]]
try [loop 9999 [try/keep [1 / 0]]]
try [loop 9999 [try/keep [1 / 0]]]
try [loop 9999 [try/keep [1 / 0]]]
@hiiamboris
Copy link
Author

hiiamboris commented Jun 29, 2021

I'm getting one of:

root: 4706/7424, runs: 0, mem: 3256212 => 2207716, mark: 2.5ms, sweep: 1.0ms
root: 4706/7424, runs: 1, mem: 3256680 => 2207680, mark: 2.0ms, sweep: 1.0ms
root: 4706/7424, runs: 2, mem: 5426984 => 2207884, mark: 2.0ms, sweep: 1.0ms
root: 4706/7424, runs: 3, mem: 5427024 => 2207848, mark: 1.0ms, sweep: 2.0ms
root: 4706/7424, runs: 4, mem: 7596976 => 2207848, mark: 3.0ms, sweep: 4.0ms
root: 4706/7424, runs: 5, mem: 7597144 => 2208016, mark: 3.0ms, sweep: 5.0ms
root: 4706/7424, runs: 6, mem: 7597144 => 2208016, mark: 2.0ms, sweep: 3.0ms
root: 4706/7424, runs: 7, mem: 7597312 => 2208184, mark: 2.0ms, sweep: 3.0ms
root: 4706/7424, runs: 8, mem: 7596596*** Internal Error: failed to release memory
*** Where: try
*** Stack:

root: 4706/7424, runs: 0, mem: 3256412 => 2212044, mark: 2.0ms, sweep: 1.0ms
root: 4706/7424, runs: 1, mem: 3256736 => 2212008, mark: 1.0ms, sweep: 1.0ms
root: 4706/7424, runs: 2, mem: 5427040 => 2212212, mark: 2.7ms, sweep: 2.0ms
root: 4706/7424, runs: 3, mem: 5427080 => 2212176, mark: 1.0ms, sweep: 2.0ms
root: 4706/7424, runs: 4, mem: 7597384root: 4706/7424, runs: 4, mem: 5426576 => 1475868, mark: 2.0ms, sweep: 3.0ms
root: 4706/7424, runs: 5, mem: 5419992
*** Runtime Error 1: access violation
*** in file: /D/devel/red/red-src/red/runtime/collector.reds
*** at line: 87
***
***   stack: red/collector/keep 00000000h
***   stack: red/collector/mark-values 02D93EA8h 02D93ED8h
***   stack: red/collector/mark-block 02930254h
***   stack: red/collector/mark-values 02930254h 02941604h
***   stack: red/collector/mark-block 00530A48h
***   stack: red/collector/do-mark-sweep
***   stack: red/collector/do-cycle
***   stack: red/alloc-series-buffer 20 16 0
***   stack: red/alloc-series 20 16 0
***   stack: red/alloc-cells 20
***   stack: red/block/make-at 057BFDE8h 20
***   stack: red/error/capture 0294C144h
***   stack: red/natives/try* false -1 1
***   stack: red/interpreter/eval-arguments 0294C134h 02C2B738h 02C2B738h 02C2B718h 02C2B698h 02A302F8h
***   stack: red/interpreter/eval-code 02A302F8h 02C2B728h 02C2B738h true 02C2B718h 02C2B698h 02A302F8h
***   stack: red/interpreter/eval-path 02C2B718h 02C2B728h 02C2B738h false false false false
***   stack: red/interpreter/eval-expression 02C2B728h 02C2B738h false false false
***   stack: red/interpreter/eval 0294C124h true
***   stack: red/natives/loop* false
***   stack: red/interpreter/eval-arguments 0294C104h 02C2B780h 02C2B780h 00000000h 00000000h 02A30AB8h
***   stack: red/interpreter/eval-code 02A30AB8h 02C2B760h 02C2B780h false 00000000h 00000000h 02A30AB8h
***   stack: red/interpreter/eval-expression 02C2B760h 02C2B780h false false false
***   stack: red/interpreter/eval 0294C0F4h true
***   stack: red/natives/try* false -1 -1
***   stack: red/interpreter/eval-arguments 0294C0E4h 02C2B9E8h 02C2BA08h 00000000h 00000000h 02A302F8h
***   stack: red/interpreter/eval-code 02A302F8h 02C2B9D8h 02C2BA08h false 00000000h 00000000h 02A302F8h
***   stack: red/interpreter/eval-expression 02C2B9D8h 02C2BA08h false false false
***   stack: red/interpreter/eval 0294C0C4h true
***   stack: red/natives/catch* true 1
***   stack: ctx||548~try-do 00F51CFCh
***   stack: ctx||548~launch 00F51CFCh
***   stack: ctx||566~launch 00F51798h

root: 4706/7424, runs: 0, mem: 3256408 => 2208032, mark: 3.0ms, sweep: 1.0ms
root: 4706/7424, runs: 1, mem: 5426980
*** Runtime Error 98: assertion failed
*** in file: /D/devel/red/red-src/red/runtime/allocator.reds
*** at line: 365
***
***   stack: red/free-node 00000062h
***   stack: red/free-node BADCAFE0h
***   stack: red/cross-compact-frame 02C10004h 00EC4920h
***   stack: red/collect-frames 1
***   stack: red/collector/do-mark-sweep
***   stack: red/collector/do-cycle
***   stack: red/alloc-series-buffer 20 16 0
***   stack: red/alloc-series 20 16 0
***   stack: red/alloc-cells 20
***   stack: red/block/make-at 02E0FDE0h 20
***   stack: red/error/capture 028DC144h
***   stack: red/natives/try* false -1 1
***   stack: red/interpreter/eval-arguments 028DC134h 02D168C8h 02D168C8h 02D168A8h 02D16828h 029C02F8h
***   stack: red/interpreter/eval-code 029C02F8h 02D168B8h 02D168C8h true 02D168A8h 02D16828h 029C02F8h
***   stack: red/interpreter/eval-path 02D168A8h 02D168B8h 02D168C8h false false false false
***   stack: red/interpreter/eval-expression 02D168B8h 02D168C8h false false false
***   stack: red/interpreter/eval 028DC124h true
***   stack: red/natives/loop* false
***   stack: red/interpreter/eval-arguments 028DC104h 02D16910h 02D16910h 00000000h 00000000h 029C0AB8h
***   stack: red/interpreter/eval-code 029C0AB8h 02D168F0h 02D16910h false 00000000h 00000000h 029C0AB8h
***   stack: red/interpreter/eval-expression 02D168F0h 02D16910h false false false
***   stack: red/interpreter/eval 028DC0F4h true
***   stack: red/natives/try* false -1 -1
***   stack: red/interpreter/eval-arguments 028DC0E4h 02D16D18h 02D16D78h 00000000h 00000000h 029C02F8h
***   stack: red/interpreter/eval-code 029C02F8h 02D16D08h 02D16D78h false 00000000h 00000000h 029C02F8h
***   stack: red/interpreter/eval-expression 02D16D08h 02D16D78h false false false
***   stack: red/interpreter/eval 028DC0C4h true
***   stack: red/natives/catch* true 1
***   stack: ctx||548~try-do 026F1CFCh
***   stack: ctx||548~launch 026F1CFCh
***   stack: ctx||566~launch 026F178Ch

@dockimbel
Copy link

Is it compiled or interpreted?

@hiiamboris
Copy link
Author

I only tried interpreted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment