Skip to content

Commit

Permalink
FIX: issue #4433 ([CRASH] when loading a big map)
Browse files Browse the repository at this point in the history
Marks values in lexer's buffer.
  • Loading branch information
qtxie authored and dockimbel committed May 16, 2020
1 parent ffde76f commit 26cd0d0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion runtime/datatypes/series.reds
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ _series: context [
if offset > len [part: 0 offset: len]
if offset + part > len [part: len - offset]

new/header: TYPE_UNSET
if ser <> new [new/header: TYPE_UNSET]
part: part << (log-b unit)
node: alloc-bytes part
s: GET_BUFFER(ser)
Expand Down
24 changes: 20 additions & 4 deletions runtime/lexer.reds
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ lexer: context [
len stype t [integer!]
do-error [subroutine!]
point? [logic!]
head [red-value!]
][
do-error: [
lex/closing: type
Expand All @@ -592,9 +593,10 @@ lexer: context [
]

len: (as-integer lex/tail - lex/head) >> 4
lex/tail: lex/head
head: lex/head
lex/head: as cell! p - p/x
store-any-block as cell! p lex/tail len type ;-- p slot gets overwritten here
store-any-block as cell! p head len type ;-- p slot gets overwritten here
lex/tail: head
lex/scanned: type

p: as red-point! lex/head - 1 ;-- get parent series
Expand Down Expand Up @@ -2276,12 +2278,26 @@ lexer: context [
zero? count
]
]


on-gc-mark: func [/local s [state!] lex [state!]][
if root-state <> null [
s: root-state
until [
lex: s
s: s/next
null? s
]
collector/mark-values stash lex/tail
]
]

init: func [][
stash: as cell! allocate stash-size * size? cell!
utf8-buffer: allocate utf8-buf-size
utf8-buf-tail: utf8-buffer


collector/register as int-ptr! :on-gc-mark

;-- switch following tables to zero-based indexing
lex-classes: lex-classes + 1
transitions: transitions + 1
Expand Down

0 comments on commit 26cd0d0

Please sign in to comment.