yeesian / ArchGDAL.jl

A high level API for GDAL - Geospatial Data Abstraction Library
https://yeesian.github.io/ArchGDAL.jl/stable/
Other
142 stars 26 forks source link

Segmentation fault on v0.7 #212

Closed evetion closed 3 years ago

evetion commented 3 years ago

In upgrading GeoDataFrames to ArchGDAL 0.7 (https://github.com/evetion/GeoDataFrames.jl/pull/21) I hit a segmentation fault. I can reproduce it to the following code on macOS when using Julia 1.6. 1.7 seems to work, but most of the platforms fail the CI in the PR.

using ArchGDAL; const AG=ArchGDAL

AG.createlayer(
    name="test",
    geom=AG.GDAL.wkbPoint,
    ) do layer
        AG.addfielddefn!(layer, "test", convert(AG.OGRFieldType, String))
end

results in

signal (11): Segmentation fault: 11
in expression starting at /Users/evetion/code/GeoDataFrames/test/runtests.jl:30
OGR_L_CreateField at /Users/evetion/.julia/artifacts/dce3145800aa7866bf5cdbedd3ac40850df3fc47/lib/libgdal.28.dylib (unknown line)
ogr_l_createfield at /Users/evetion/.julia/packages/GDAL/5CClC/src/ogr_api.jl:4526 [inlined]
addfielddefn! at /Users/evetion/.julia/packages/ArchGDAL/wt2FK/src/ogr/featurelayer.jl:818 [inlined]
addfielddefn! at /Users/evetion/.julia/packages/ArchGDAL/wt2FK/src/ogr/featurelayer.jl:818 [inlined]
#addfielddefn!#221 at /Users/evetion/.julia/packages/ArchGDAL/wt2FK/src/context.jl:123
addfielddefn! at /Users/evetion/.julia/packages/ArchGDAL/wt2FK/src/context.jl:114 [inlined]
#12 at /Users/evetion/code/GeoDataFrames/src/io.jl:54
#createlayer#239 at /Users/evetion/.julia/packages/ArchGDAL/wt2FK/src/context.jl:267
createlayer##kw at /Users/evetion/.julia/packages/ArchGDAL/wt2FK/src/context.jl:265 [inlined]
#11 at /Users/evetion/code/GeoDataFrames/src/io.jl:47 [inlined]
#create#229 at /Users/evetion/.julia/packages/ArchGDAL/wt2FK/src/context.jl:267
create##kw at /Users/evetion/.julia/packages/ArchGDAL/wt2FK/src/context.jl:265 [inlined]
#write#10 at /Users/evetion/code/GeoDataFrames/src/io.jl:43
write at /Users/evetion/code/GeoDataFrames/src/io.jl:20
yeesian commented 3 years ago

I'm not able to reproduce the error in https://github.com/yeesian/ArchGDAL.jl/issues/212#issue-934796989, but it resulted in an error for me nonetheless:

  | | |_| | | | (_| |  |  Version 1.6.0 (2021-03-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using ArchGDAL; const AG=ArchGDAL
ArchGDAL

julia> AG.createlayer(
           name="test",
           geom=AG.GDAL.wkbPoint,
           ) do layer
               AG.addfielddefn!(layer, "test", convert(AG.OGRFieldType, String))
       end
ERROR: TypeError: in keyword argument geom, expected ArchGDAL.OGRwkbGeometryType, got a value of type GDAL.OGRwkbGeometryType
Stacktrace:
 [1] createlayer(::var"#3#4"; kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:name, :geom), Tuple{String, GDAL.OGRwkbGeometryType}}})
   @ ArchGDAL ~/.julia/packages/ArchGDAL/IuyJL/src/context.jl:265
 [2] top-level scope
   @ REPL[2]:1

Here's the environment:

(@v1.6) pkg> st
      Status `~/.julia/environments/v1.6/Project.toml`
  [4c88cf16] Aqua v0.5.0
  [c9ce4bd3] ArchGDAL v0.7.0
  [6e4b80f9] BenchmarkTools v0.5.0
  [12aac903] BinaryBuilder v0.3.3
  [fa961155] CEnum v0.4.1
  [3da002f7] ColorTypes v0.11.0
  [a93c6f00] DataFrames v1.0.1
  [3c3547ce] DiskArrays v0.2.7
  [e30172f5] Documenter v0.26.3
  [add2ef01] GDAL v1.2.1
  [cf35fbd7] GeoInterface v0.5.5
  [a09fc81d] ImageCore v0.9.0
  [d8c32880] ImageInTerminal v0.4.6
  [98e50ef6] JuliaFormatter v0.13.10
  [32113eaa] PkgBenchmark v0.2.10
  [91a5bcdd] Plots v1.13.2
  [295af30f] Revise v3.1.15
  [aa65fe97] SnoopCompile v2.6.0
  [e2b509da] SnoopCompileCore v2.5.2
  [bd369af6] Tables v1.4.2
  [d3a6a179] TerminalExtensions v0.4.0
yeesian commented 3 years ago

Am now able to reproduce when I replace AG.GDAL.wkbPoint with AG.wkbPoint in https://github.com/yeesian/ArchGDAL.jl/issues/212#issue-934796989.