timholy / SnoopCompile.jl

Provide insights about latency (TTFX) for Julia packages
https://timholy.github.io/SnoopCompile.jl/dev/
Other
309 stars 48 forks source link

MethodError: no method matching String(::Expr) #266

Open letalvoj opened 3 years ago

letalvoj commented 3 years ago

Julia 1.5.4, SnoopCompile 2.7.1

data = SnoopCompile.read("7464124.snoop")
pc = SnoopCompile.parcel(reverse!(data[2]))

yields

ERROR: LoadError: MethodError: no method matching String(::Expr)
Closest candidates are:
  String(::String) at boot.jl:337
  String(::Array{UInt8,1}) at strings/string.jl:39
  String(::Base.CodeUnits{UInt8,String}) at strings/string.jl:77
  ...
Stacktrace:
 [1] parse_call(::String; subst::Array{Pair{String,String},1}, exclusions::Array{String,1}) at /Users/vojtech.letal/.julia/packages/SnoopCompile/Y17OY/src/parcel_snoopc.jl:89
 [2] format_userimg(::Array{String,1}; subst::Array{Pair{String,String},1}, exclusions::Array{String,1}) at /Users/vojtech.letal/.julia/packages/SnoopCompile/Y17OY/src/parcel_snoopc.jl:184
 [3] format_userimg(::Array{String,1}) at /Users/vojtech.letal/.julia/packages/SnoopCompile/Y17OY/src/parcel_snoopc.jl:182

it's this line

https://github.com/timholy/SnoopCompile.jl/blob/5ad2f249a4c331b50067192f850b01fbd52218d2/src/parcel_snoopc.jl#L89

Seems like there is a test covering that very method. If I manage to fix that issue I will submit a pr

https://github.com/timholy/SnoopCompile.jl/blob/a75d41856849be2d661163bbce184f71f5a3ae8d/test/colortypes.jl#L4

letalvoj commented 3 years ago

Ok. These should be all Symbol according to the test suite. I have no idea why I get Expr there. The snooped compilation is pretty large and it uses macros, Flux, HTTP, ... 🤷

letalvoj commented 3 years ago

A workaround which might just produce incorrect results yet it works for what I needed it to was to replace

name = String(name)::String

with

name = string(name)::String
timholy commented 3 years ago

I'd be fine with a PR that does that, especially if it came with a test! I don't know how to trigger this, but if you do...

letalvoj commented 3 years ago

Yeah, it's most likely wrong for the ::Expr type ... If I fix it such that it makes sense I'll send a PR for sure 👍

pkofod commented 2 years ago

Yeah, I'm hitting this as well when benchmarking code. I can share a private reproducer if you want @timholy

timholy commented 2 years ago

Yeah, I'd take a reproducer!

pkofod commented 2 years ago

It's not minimal, but I'll e-mail it.

letalvoj commented 2 years ago

@pkofod did you manage to find out the root cause?

PharmCat commented 1 year ago

Hello! Is any thoughts how to fix it locally?

timholy commented 1 year ago

Recommended practice these days is to use SnoopPrecompile. I'd recommend switching.