Skip to content
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

Writing a Raster to tif crashes Julia on apple M2 #343

Closed
luraess opened this issue Dec 1, 2022 · 12 comments
Closed

Writing a Raster to tif crashes Julia on apple M2 #343

luraess opened this issue Dec 1, 2022 · 12 comments

Comments

@luraess
Copy link

luraess commented Dec 1, 2022

I may do something not optimal here, but writing any Raster to disk results in the following Bus error leading to the crash of Julia.

julia> using Rasters

julia> A = Raster("tos_O1_2001-2002.nc")

julia> B = A[20:30,40:50,1]

julia> write("outB.tif",B)

signal (10): Bus error: 10
in expression starting at REPL[4]:1
unknown function (ip: 0x126e48af8)
Allocations: 42057194 (Pool: 42041755; Big: 15439); GC: 34

This is on M2 chip Mac:

julia> versioninfo()
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 8 × Apple M2
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 4 on 4 virtual cores
Environment:
  JULIA_NUM_THREADS = 4
@rafaqz
Copy link
Owner

rafaqz commented Dec 2, 2022

I can't reproduce this, could it be an apple M2/rosetta problem? (likely in the netcdf binary rather than this package)

@rafaqz rafaqz changed the title Writing a Raster to disk crashes Julia Writing a Raster to netcdf crashes Julia on apple M2 Dec 2, 2022
@luraess
Copy link
Author

luraess commented Dec 2, 2022

Yes. It is certainly a M2 related issue. Where should the issue then be reported precisely?

@rafaqz
Copy link
Owner

rafaqz commented Dec 2, 2022

Maybe try writing the same thing with NCDatasets.jl without using Rasters.jl. If it happens there too then that's the place.

But even then, it might be in the C code binary NCDatasets.jl is calling

@luraess
Copy link
Author

luraess commented Dec 2, 2022

Thanks. Will do so!

@luraess
Copy link
Author

luraess commented Dec 3, 2022

Interestingly, using only NCDatasets.jl generates an error if not using absolute path

julia> ds = NCDataset("./tmp/test.nc","c")
ERROR: NetCDF error: Permission denied (NetCDF error code: 13)
Stacktrace:
 [1] check
   @ ~/.julia/packages/NCDatasets/h1epE/src/errorhandling.jl:25 [inlined]
 [2] nc_create(path::String, cmode::UInt16)
   @ NCDatasets ~/.julia/packages/NCDatasets/h1epE/src/netcdf_c.jl:255
 [3] NCDataset(filename::String, mode::String; format::Symbol, share::Bool, diskless::Bool, persist::Bool, memory::Nothing, attrib::Vector{Any})
   @ NCDatasets ~/.julia/packages/NCDatasets/h1epE/src/dataset.jl:222
 [4] NCDataset(filename::String, mode::String)
   @ NCDatasets ~/.julia/packages/NCDatasets/h1epE/src/dataset.jl:163
 [5] top-level scope
   @ REPL[6]:3

However, using absolute path works.

Trying to use absolute path in write function having loaded Rasters.jl still results in

julia> write(joinpath(@__DIR__, "out_1.tif"), a)

signal (10): Bus error: 10
in expression starting at REPL[7]:1
unknown function (ip: 0x126e48af8)
Allocations: 52762119 (Pool: 52741466; Big: 20653); GC: 29
zsh: bus error

@luraess
Copy link
Author

luraess commented Dec 6, 2022

Does Rasters.jl directly use NCDataset as write function? Since it seems to partly work with NCDataset, do you have any idea what could wrong and generate the crash?

@rafaqz
Copy link
Owner

rafaqz commented Dec 6, 2022

Yes it's using NCDatasets.jl to write. But maybe some different options are triggering this bug. I'll have a look to see what it could be, but it will be hard without a mac handy.

Is that the full error message? If I can see a stack trace we can maybe find out a bit more.

@luraess
Copy link
Author

luraess commented Dec 6, 2022

Is that the full error message? If I can see a stack trace we can maybe find out a bit more.

In Julia yes. I don't know if I can get more out of Bus error from e.g. system logs or so.

@rafaqz
Copy link
Owner

rafaqz commented Dec 6, 2022

Yes it's hard to debug without a stack trace

@evetion
Copy link

evetion commented Feb 21, 2023

@luraess Could you test on say, 1.8.1? This feels like JuliaLang/julia#47193, although that turned out to be a problem in ArchGDAL (which was triggered by some changes in Julia itself).

@rafaqz
Copy link
Owner

rafaqz commented Feb 21, 2023

Turns out I was thrown by the inccorect issue title and mix of .nc and .tif extenstions being used - this is actually ArchGDAL.jl writing.

@rafaqz rafaqz changed the title Writing a Raster to netcdf crashes Julia on apple M2 Writing a Raster to tif crashes Julia on apple M2 Feb 21, 2023
@evetion
Copy link

evetion commented Feb 21, 2023

In that case, it should be fixed when using ArchGDAL >=0.9.4

@rafaqz rafaqz closed this as completed Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants