Skip to content

Memory corruption in 0.9.3 #71

@kbarros

Description

@kbarros

We have noticed intermittent crashes since upgrading from Spglib 0.9.2 to 0.9.3. Looks like the only real difference between these versions is the switch from enums to SumTypes: singularitti/Spglib.jl@819b7f6.

Perhaps there is memory corruption when reading an spglib_jll response into a sum type?

Frequently the result is a segfault, but here is one stacktrace we got that seems interpretable:

Failed to precompile Sunny [2b4a2ac8-8f8b-43e8-abf4-3cb0c45e8736] to "/home/runner/.julia/compiled/v1.9/Sunny/jl_GxA1Pq".
ERROR: LoadError: ArgumentError: cannot convert NULL to string
Stacktrace:
  [1] unsafe_string
    @ ./strings/string.jl:84 [inlined]
  [2] unsafe_string
    @ ./c.jl:193 [inlined]
  [3] get_error_message(code::Spglib.SpglibReturnCode)
    @ Spglib ~/.julia/packages/Spglib/rGUIW/src/error.jl:37
  [4] check_error
    @ ~/.julia/packages/Spglib/rGUIW/src/error.jl:50 [inlined]
  [5] get_spacegroup_type(hall_number::Int64)
    @ Spglib ~/.julia/packages/Spglib/rGUIW/src/symmetry.jl:291
  [...]

This appeared on our Github actions CI with Julia 1.9.4, Ubuntu, x86. Full trace here: https://github.com/SunnySuite/Sunny.jl/actions/runs/7629267203/job/20782289111?pr=217

I haven't seen the crashes yet on my Mac. On Linux/x86, reproducing might be as simple as ] add Sunny#spglib_crash and then using Sunny.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions