dimanche 15 février 2015

Swift REPL mode random crash with reflect

After learning about reflect() to learn types dynamically, I started using it and getting this curious crash:



# swift -version
Swift version 1.1 (swift-600.0.56.1)
Target: x86_64-apple-darwin14.1.0
# swift
Welcome to Swift! Type :help for assistance.
1> println(reflect({1}))
Swift._OpaqueMirror
2> reflect({1})
Segmentation fault: 11


HOWEVER:



1> reflect({1}).dynamicType
$R0: MirrorType.Type = Swift._OpaqueMirror


This behavior is repeatable and the hardware / OS (10.10.2) is otherwise operating well. There's also a noticeable pause during evaluation as if a stack or buffer is overflowing. Variations such as using a variable assigned to the closure and reflecting on the variable also crash. Finally: running swift within lldb makes it work with proper output!!



[...]
(lldb) c
Process 3322 resuming
Welcome to Swift! Type :help for assistance.
1> reflect({"a"})
reflect({"a"})
$R0: _OpaqueMirror = {
data = {
owner = {}
ptr = {}
metadata = 0x07fad7e8ffffff40
}
}


Any insights?






Aucun commentaire:

Enregistrer un commentaire