Skip to content

Conversation

@JeffBezanson
Copy link
Member

Also change jl_get_backtrace to return a pair of values instead of mutating. This seems to have been missing a write barrier, plus jl_backtrace_from_here is very similar and already returns a pair, so might as well make them match.

fix #32678

Also change `jl_get_backtrace` to return a pair of values instead of
mutating.
@JeffBezanson JeffBezanson added the bugfix This change fixes an existing bug label Oct 10, 2019
while i <= length(bt)
ip = bt[i]::Ptr{Cvoid}
if ip == Ptr{Cvoid}(-1%UInt)
if UInt(ip) == (-1 % UInt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the issue is that we make this -1 Ptr into a literal and then don't serialize it properly. That seems ... bad?

Copy link
Member Author

@JeffBezanson JeffBezanson Oct 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we save all pointers as NULL so that we can detect that an object is uninitialized at run time, and re-create the needed native objects. Interestingly dump.c has this:

        if (t->name == jl_pointer_typename && jl_unbox_voidpointer(v) != (void*)-1) {
            // normalize most pointers to NULL, to help catch memory errors
            // but permit MAP_FAILED / INVALID_HANDLE to be stored unchanged

but staticdata.c doesn't have the special case for -1. @vtjnash & I discussed limiting this somehow, e.g. only nulling mutable object fields.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is particularly bad because the user didn't write @eval :($(Ptr{Cvoid}(-1%UInt))), but just the code Ptr{Cvoid}(-1%UInt). The fact that we construct and inline that pointer in the IR is just something the compiler does. Perhaps we need to prevent inference from creating Const Ptrs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, stopping inference from embedding pointers would probably be a better plan

@JeffBezanson JeffBezanson merged commit cf5957e into master Oct 11, 2019
@JeffBezanson JeffBezanson deleted the jb/fix32678 branch October 11, 2019 17:38
return bt;
}

// note: btout and bt2out must be GC roots
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little surprised the static analyzer is ok with this; I believe these should be marked with JL_REQUIRE_ROOTED_SLOT? I can add that tweak in #33277 where I'm touching the same code anyway.

@KristofferC
Copy link
Member

Can this be backported? It happens all the time when dealing with package compilation stuff.

@c42f
Copy link
Member

c42f commented Oct 23, 2019

Yes I think it would be sufficient to backport only the single line with the if UInt(ip) == (-1 % UInt). The rest is code cleanup.

@KristofferC KristofferC mentioned this pull request Nov 15, 2019
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This change fixes an existing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem with _reformat_bt?

6 participants