-
Notifications
You must be signed in to change notification settings - Fork 10
Trace ptr_or_offset in jl_genericmemoryref_t #252
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
base: mmtk-support-moving-upstream
Are you sure you want to change the base?
Trace ptr_or_offset in jl_genericmemoryref_t #252
Conversation
4340bc9
to
d6744a7
Compare
Did that actually fix the issue? I remember implementing something like that and that it didn't work. I believe what I did to reproduce the issue was running |
I think these tests would always fail: https://github.com/mmtk/julia/blob/a3d4e393dc871b8dbe1f7d105ca9d0a9d98864b6/test/atomics.jl#L877 |
I will try with |
mmtk/src/julia_scanning.rs
Outdated
@@ -363,6 +368,11 @@ pub unsafe fn scan_julia_object<SV: SlotVisitor<JuliaVMSlot>>(obj: Address, clos | |||
return; | |||
} | |||
|
|||
if (*vt).name == jl_genericmemoryref_typename { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d-netto Is it possible that we're not tracing all jl_genericmemoryref_t
objects with that check? I remember I had some code to simply print out if those objects were scanned when running the atomics test but for some reason nothing was being printed out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just more info for the discussion. In the runtime code, we can see that jl_genericmemoryref_t
may be used as a value (rather than as a pointer to heap objects) -- the ref in jl_array_t is an example, there are a few functions that return jl_genericmemoryref_t
as a value -- so objects of this type may be stored outside the heap, like stacks, global memory, native heap, etc. We should be fine with stacks. But if it appears in global memory, or native heap, or anywhere else, we would have an issue -- though I don't know if that happens or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the delay. Will take a look soon.
The test still failed. Will look more into it tomorrow. |
I added a hack that deals with |
Just as a note: in our dev branch n = 15
a = zeros(Bool, n)
# a gets moved, but it is correct.
GC.gc()
# ptr_or_offset and mem for a8 do not point to the same object
a8 = unsafe_wrap(Array, Ptr{UInt8}(pointer(a)), length(a); own=false) # unsafely observe the actual bit patterns in `a`
# a8 gets moved, and its ptr_or_offset field does not get updated correctly by GC
GC.gc()
println(a) # a is an array of 0s.
println(a8) # a8's pointer is dangling, and points to corrupted memory. |
fb3f50d changed the location of the forwarding pointer from -64 (bits) to 0. So at least it won't overwrite the object type. It still overwrites the object payload, and causes errors for size calculation. Currently we only trace internal pointers for a few limited number of types, so we are fine at the moment. But anyway, it is still a hack. mmtk/mmtk-core#1331 needs to be resolved, then we can properly use |
See #249 (comment).