-
Notifications
You must be signed in to change notification settings - Fork 9
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
OpenTelemetry with PythonCall can yield LLVM ERROR: Cannot emit physreg copy instruction #80
Comments
Hi @MartinWolke , I can't reproduce this error on my linux environment with [email protected] . https://github.com/JuliaLang/julia/issues?q=is%3Aissue+physreg+is%3Aclosed So I'm tagging @vtjnash here. Maybe Jameson is familiar with such errors. |
Hi @findmyway , thanks for checking this out! That's very interesting; Maybe it's something particular to the Linux versions or the Python versions that I was using. I'll have a look and try different setups and document my findings here. I was able to narrow down the point at which Julia crashes: using OpenTelemetry
using OpenTelemetry.OpenTelemetryAPI
using OpenTelemetry.OpenTelemetrySDK
using PythonCall
tracer = Tracer()
span = OpenTelemetryAPI.create_span("foo", tracer)
# this works
span.status[] = OpenTelemetryAPI.SpanStatus(
OpenTelemetryAPI.SPAN_STATUS_ERROR, nothing
)
## this works, too
function foo(status)
return span.status[] = status
end
status = OpenTelemetryAPI.SpanStatus(
OpenTelemetryAPI.SPAN_STATUS_ERROR, nothing
)
foo(status)
## this crashes Julia
function foo(s, code, description=nothing)
return s.status[] = OpenTelemetryAPI.SpanStatus(code, description)
end
foo(span, OpenTelemetryAPI.SPAN_STATUS_ERROR) I have no clue why the last example crashes Julia while the prior ones do not.
and
With this information, I tried the following code which seems to work for me: function my_span_status!(
span::OpenTelemetrySDK.Span, status::OpenTelemetryAPI.SpanStatus
)
if OpenTelemetryAPI.is_recording(span)
if span.status[].code === OpenTelemetryAPI.SPAN_STATUS_OK
# no further updates
else
if code === OpenTelemetryAPI.SPAN_STATUS_UNSET
# ignore
else
span.status[] = status
end
end
else
@warn "the span is not recording."
end
end
function OpenTelemetryAPI.with_span(
f::Function,
name::String,
tracer::OpenTelemetryAPI.Tracer=OpenTelemetryAPI.Tracer();
end_on_exit=true,
record_exception=true,
set_status_on_exception=true,
kw...,
)
s = OpenTelemetryAPI.create_span(name, tracer; kw...)
OpenTelemetryAPI.with_context(;
OpenTelemetryAPI.SPAN_KEY_IN_CONTEXT => s
) do
try
f()
catch ex
if OpenTelemetryAPI.is_recording(s)
if record_exception
push!(s, ex; is_rethrow_followed=true)
end
if set_status_on_exception
status = OpenTelemetryAPI.SpanStatus(
OpenTelemetryAPI.SPAN_STATUS_ERROR, string(ex)
)
my_span_status!(s, status)
end
end
rethrow(ex)
finally
if end_on_exit
OpenTelemetryAPI.end_span!(s)
end
end
end
end |
I get an assertion error in codegen on this, so it is like a Julia bug. I see there is a package being used (by PythonCall) called UnsafePointers, and inference is accidentally inferring it might be used on a struct called SpanStatus. The struct SpanStatus does not have a C-compatible definition, so it is not well defined what happens when you use it with unsafe pointer-based operations. But this is in dead-code, so codegen should not crash. The error could likely also be avoided by removing uses of |
Hi!
Thank you for writing this package; it's awesome!
I've been experimenting with
OpenTelemetry
(OpenTelemetry v0.3.0
) and stumbled over a weird interaction when combined with thePythonCall
(PythonCall v0.9.13
) Package. Running the following code reliably crashes Julia (I tried with Julia 1.9.0, Julia 1.9.1, and Julia 1.8.5; all installed with Juliaup) for me.The weird thing is that
PythonCall
isn't even used.Julia crashes with
Do you have any idea what might cause the issue? I couldn't find anything so far. I'll post a complete stack trace below.
The text was updated successfully, but these errors were encountered: