JuliaIO / JLD2.jl

HDF5-compatible file format in pure Julia
Other
549 stars 85 forks source link

Can't save stackframe() #413

Closed louisponet closed 1 year ago

louisponet commented 2 years ago

MWE:

using JLD2
JLD2.save("test.jld2", "stack", stackframe())

Is there a reason why this shouldn't work?

JonasIsensee commented 2 years ago

Hi @louisponet ,

StackFrames contain quite objects from Core and therefore references connected to julia C internals. This is an absolute nightmare to support. (Hard to debug and can change between julia releases)

For such things it is probably best to use the Serialization standard lib. In case you would still like to use JLD2 as a container format for storing additional metadata or so, have a look at #377. It shows you one possible way to use CustomSerialization to embedd binary payloads into JLD2 files.

julia> dump(Base.StackTraces.StackFrame)
Base.StackTraces.StackFrame <: Any
  func::Symbol
  file::Symbol
  line::Int64
  linfo::Union{Nothing, Core.CodeInfo, Core.MethodInstance}
  from_c::Bool
  inlined::Bool
  pointer::UInt64
louisponet commented 2 years ago

Yeah I thought it must have been something like that. I dug a bit myself and found pointers and whatnot in the stackframes (which I thought would be just a representation), and realized that's probably the issue. I also once tried saving tasks and there it was clearer to me why that wouldn't work.

Thank you for the suggestions, I'll experiment with those a bit!

Cheers