From caab5c917ffd4a4c583dad9c59d2e1012eee9baa Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 22 Apr 2020 21:26:31 +0300 Subject: [PATCH] Don't use destructors --- faststreams/input_stream.nim | 6 ++++++ faststreams/output_stream.nim | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/faststreams/input_stream.nim b/faststreams/input_stream.nim index d2aa8ce..0c1894d 100644 --- a/faststreams/input_stream.nim +++ b/faststreams/input_stream.nim @@ -65,6 +65,11 @@ proc close*(s: InputStream) {.raises: [IOError, Defect].} = s.preventFurtherReading() +# TODO +# The destructors are currently disabled because they seem to cause +# mysterious segmentation faults related to corrupted GC internal +# data structures. +#[ proc `=destroy`*(h: var InputStreamHandle) {.raises: [Defect].} = if h.s != nil: if h.s.vtable != nil and h.s.vtable.closeSync != nil: @@ -82,6 +87,7 @@ proc `=destroy`*(h: var InputStreamHandle) {.raises: [Defect].} = # We work-around the problem through more indirect incapacitatation # of the stream object: h.s.preventFurtherReading() +]# converter implicitDeref*(h: InputStreamHandle): InputStream = h.s diff --git a/faststreams/output_stream.nim b/faststreams/output_stream.nim index 8b33962..e49b512 100644 --- a/faststreams/output_stream.nim +++ b/faststreams/output_stream.nim @@ -72,6 +72,11 @@ proc close*(s: OutputStream) {.raises: [IOError, Defect].} = if s.vtable != nil and s.vtable.closeSync != nil: s.vtable.closeSync(s) +# TODO +# The destructors are currently disabled because they seem to cause +# mysterious segmentation faults related to corrupted GC internal +# data structures. +#[ proc `=destroy`*(h: var OutputStreamHandle) {.raises: [Defect].} = if h.s != nil: if h.s.vtable != nil and h.s.vtable.closeSync != nil: @@ -83,6 +88,7 @@ proc `=destroy`*(h: var OutputStreamHandle) {.raises: [Defect].} = # `close` manually. discard # TODO # h.s = nil +]# converter implicitDeref*(h: OutputStreamHandle): OutputStream = h.s