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

CPLDestroyMutex: Error = 16 (Device or resource busy) #241

Closed evetion closed 3 years ago

evetion commented 3 years ago

This is something that happens on the exit of many tests over at GeoArrays, but I see the same here in the tests: https://github.com/yeesian/ArchGDAL.jl/runs/3502488899?check_suite_focus=true#step:6:67

I'd say this is something that shouldn't happen, but I'm not sure. @visr any thoughts?

visr commented 3 years ago

Not directly. Something is perhaps not closed in the right order or something like that. Do you have a small example that we can start testing this out?

mathieu17g commented 3 years ago

The error message appears with Pkg.test("ArchGDAL") but not with include("runtests.jl") from the test directory

@visr have you already look into the possibility to make for Julia something equivalent of Python's <module>.UseExceptions() ? This in order to identify better where the error message from come from.

visr commented 3 years ago

I think we have that, and it's enabled by default. Evey time you get a GDALError it is a Julia Exception thrown by an error in GDAL, see https://github.com/JuliaGeo/GDAL.jl/blob/master/src/error.jl.

If you can reliably trigger the issue, perhaps the quickest way to locate it is with some print statements in between the tests. Not sure why there is a difference between how you run the tests, unless the session and hence the handles are kept alive in one case but not the other.

mathieu17g commented 3 years ago

I have browsed the code of GDAL.jl/src/error.jl and GDAL.jl/gen/epilogue.jl, it is a really nice work you did there.

By commenting all includes and uncommenting then one by one in ArchGDAL/test/runtests.jl and running Pkg.test("ArchGDAL"), here are my findings:

visr commented 3 years ago

Thanks!

Ok so probably the issue is in test_gdalutilities.jl. The @time can probably be removed, and indeed good to add a GDAL import to test_images.jl. For the warning, perhaps you can test/remove it by testing with https://docs.julialang.org/en/v1/stdlib/Test/#Test.@test_warn? Would be nice to not see it.

mathieu17g commented 3 years ago

Ok so probably the issue is in test_gdalutilities.jl

Narrowing a bit more, it happens in tests @test_throws GDAL.GDALError .... Something seems to need a release

visr commented 3 years ago

Looks like this is not in a do-block that automatically closes it, nor is it manually closed: https://github.com/yeesian/ArchGDAL.jl/blob/8f820c77c790d6166f03f17f145a4ffe474933de/test/test_gdalutilities.jl#L186

mathieu17g commented 3 years ago

Well it also happens here with a dataset closed with a do block :

https://github.com/yeesian/ArchGDAL.jl/blob/8f820c77c790d6166f03f17f145a4ffe474933de/test/test_gdalutilities.jl#L5-L33

visr commented 3 years ago

This is the same file that is opened several times. Could it be that the handle is left open at line 186 causes issues at line 6 in a subsequent run?

mathieu17g commented 3 years ago

Ok I will move everything I can to a do block form, to see what happens.

mathieu17g commented 3 years ago

@visr I will make a PR to share code, because the issue seems to be trickier than expected.