-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deepcopy in arc crashes #15405
Comments
I don't see how you can get all child objects of the given base object to fix it. |
The compiler has no such data-structure that would allow for that. :-) |
Any idea how it can be fixed? running |
Seems like |
IMO, in arc mode Unless we start calling |
That means we always get the V1 type info bloat. Thinking about a better way... |
There is a good workaround which IMO we should officially document: template enableDeepCopy(x) =
discard getTypeInfo(x)
import parsexml, streams
const test_xml_str = "<A><B>value</B></A>"
var stream = newStringStream(test_xml_str)
enableDeepCopy(stream)
var xml: XmlParser
open(xml, stream, "test")
var xml2 = deepCopy(xml) |
Workaround doesn't work if you don't have accesss to internals of the objects. Imagine you have only var xml: XmlParser
enableDeepCopy(xml) You need to do: enableDeepCopy(xml.f1) # but f1 is not exported and its type is not exported either
enableDeepCopy(xml.f2) # but f2 is not exported and its type is not exported either Also xnk f1 can contain ref to base type not the actual type you want to be enabled. |
The question is: Does the workaround work for you? |
It helps me to progress in arc adoption. It helps with the deecopies in the parsers, there is one more deepcopy that will be hard to workaround like that but my code crashes before this step, investigating. |
I have come across an issue as follows:
Works without --gc:arc and crashes with. If you put all together into one module is works with AND without --gc:arc:
|
Sorry, messed up #2 above. Should be as follows:
|
* fix nim-lang#15405 * fix tests * deepcopy for ARC has to be enabled via --deepcopy:on Co-authored-by: Araq <rumpf_a@web.de>
Deepcopy recently appeared for arc runtime, first test results.
Test case:
Crashes on the nil pointer dereference with stacktrace:
I have done a bit of investigation.:
.typeInfoV1
member is nil for theNTIv2
struct of theStringStreamObj
object.typeInfoV1
is not nil forStreamObj
which is inheritance base forStringStreamObj
. AFAIK,genTypeInfoV1
codegen is done only for typeBaseLexer
that includes reference toStreamObj
. BecauseStringStreamObj
is not directly referenced,genTypeInfoV1
is not executed for it.The text was updated successfully, but these errors were encountered: