janet-lang / spork

Various Janet utility modules - the official "Contrib" library.
MIT License
124 stars 36 forks source link

spork/json crashes janet on cycles #155

Closed tionis closed 1 year ago

tionis commented 1 year ago

Example:

(import spork/json)
(def one @{:links @[]})
(def two @{:links @[one]})
(array/push (one :links) two)
(def objects @{:one one :two two})
(printf "%P" objects) #=> @{:one @{:links @[@{:links @[<cycle 1>]}]} :two @{:links @[@{:links @[<cycle 1>]}]}}
(print (json/encode objects)) #=> 'command janet $argv' terminated by signal SIGSEGV (Address boundary error)

Expected behaviour:

This should probably throw a parsing error or something like that