Don't use destructors

This commit is contained in:
Zahary Karadjov 2020-04-22 21:26:31 +03:00
commit caab5c917f
No known key found for this signature in database
GPG key ID: C8936F8A3073D609
2 changed files with 12 additions and 0 deletions

View file

@ -65,6 +65,11 @@ proc close*(s: InputStream) {.raises: [IOError, Defect].} =
s.preventFurtherReading() 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].} = proc `=destroy`*(h: var InputStreamHandle) {.raises: [Defect].} =
if h.s != nil: if h.s != nil:
if h.s.vtable != nil and h.s.vtable.closeSync != 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 # We work-around the problem through more indirect incapacitatation
# of the stream object: # of the stream object:
h.s.preventFurtherReading() h.s.preventFurtherReading()
]#
converter implicitDeref*(h: InputStreamHandle): InputStream = converter implicitDeref*(h: InputStreamHandle): InputStream =
h.s h.s

View file

@ -72,6 +72,11 @@ proc close*(s: OutputStream) {.raises: [IOError, Defect].} =
if s.vtable != nil and s.vtable.closeSync != nil: if s.vtable != nil and s.vtable.closeSync != nil:
s.vtable.closeSync(s) 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].} = proc `=destroy`*(h: var OutputStreamHandle) {.raises: [Defect].} =
if h.s != nil: if h.s != nil:
if h.s.vtable != nil and h.s.vtable.closeSync != 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. # `close` manually.
discard # TODO discard # TODO
# h.s = nil # h.s = nil
]#
converter implicitDeref*(h: OutputStreamHandle): OutputStream = converter implicitDeref*(h: OutputStreamHandle): OutputStream =
h.s h.s