Serializing a long list produces a StackOverFlowError. Serializing and deserializing a shorter list fails if done twice in a row.
--8<----8<----8<----8<----8<----8<--
;; a utility module
(module ser-deser
(ser deser ser-deser)
(import s2j)
(define-java-classes
(<object-output-stream> |java.io.ObjectOutputStream|)
(<file-output-stream> |java.io.FileOutputStream|)
(<object-input-stream> |java.io.ObjectInputStream|)
(<file-input-stream> |java.io.FileInputStream|))
(define-generic-java-methods
read-object write-object)
(define (ser-deser value)
(ser value)
(deser))
(define (ser value)
(write-object (java-new <object-output-stream>
(java-new <file-output-stream>
(->jstring "value.ser")))
(java-wrap value)))
(define (deser)
(java-unwrap (read-object (java-new <object-input-stream>
(java-new <file-input-stream>
(->jstring "value.ser"))))))
)
(import ser-deser)
(require-library 'sisc/libs/srfi/srfi-1)
(import srfi-1)
;; TEST CASE 1
(ser (iota 10000))
; => java.lang.StackOverflowError
;; TEST CASE 2
(ser (iota 10000)) ; => ok
(ser-deser (iota 10000)) ; => ok
(ser-deser (iota 10000)) ; => java.lang.StackOverflowError
;; TEST CASE 3
(ser-deser (fold (lambda (n acc)
(make-child-environment acc)) (null-environment 0) (iota 1000)))
--8<----8<----8<----8<----8<----8<--
Logged In: YES
user_id=544263
Originator: YES
Reposting the second test case. The parameter to iota should be 1E3, not 1E4.
;; TEST CASE 2
(ser (iota 1000)) ; => ok
(ser-deser (iota 1000)) ; => ok
(ser-deser (iota 1000)) ; => java.lang.StackOverflowError
Logged In: YES
user_id=25869
Originator: NO
Unfortunately this is a side effect of ObjectOutputStream not being able to serialize long chains of objects. Since OOS handles the serialization in the case of an ObjectOutputStream, rather than SISC's serialization, you're limited to stack size for them. The workaround is to increase the stack size, or use SISC's serialization which uses the heap to trace through deeply nested values.