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

HDF5.jl triggers segfault in ccall with openmp+clang(m1) with julia 1.10 #1134

Closed
mloubout opened this issue Jan 2, 2024 · 20 comments
Closed

Comments

@mloubout
Copy link

mloubout commented Jan 2, 2024

So I ran into this issue while trying out the new release of Julia (1.10).

For context, I work with code generation which can be summarized as calling C libraries, and in some case I need HDF5.jl to load datasets. I was able to simplify my issue to the following MFE

#include <omp.h>
#include <stdio.h>
 
int main()
{
    #pragma omp parallel for num_threads(4)
    for (int i = 1; i <= 10; i++) {
        int tid = omp_get_thread_num();
        printf("The thread %d  executes i = %d\n", tid, i);
    }
    return 0;
}

Compiled as a shared library with clang, this is llvm clang 17 (threw brew) with the corresponding brew libomp

clang -O3 -g -fPIC -Wall -std=c99 -Wno-unused-result -Wno-unused-variable -ffast-math -Xclang -I/opt/homebrew/opt/llvm/include -shared -mcpu=apple-m1 -fopenmp -L/opt/homebrew/opt/llvm/lib debug.c  -lm -o debug.dylib

Then call it from julia:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> @ccall "./debug.dylib".main()::Cint
The thread 0  executes i = 1
The thread 0  executes i = 2
The thread 0  executes i = 3
The thread 2  executes i = 7
The thread 2  executes i = 8
The thread 3  executes i = 9
The thread 3  executes i = 10
The thread 1  executes i = 4
The thread 1  executes i = 5
The thread 1  executes i = 6

And it's all good. But when I first use HDF5.jl then i get a segfault

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using HDF5

julia> @ccall "./debug.dylib".main()::Cint
The thread 0  executes i = 1
The thread 3  executes i = 9
The thread 3  executes i = 10
The thread 1  executes i = 4
The thread 1  executes i = 5
The thread 1  executes i = 6
The thread 2  executes i = 7
The thread 2  executes i = 8
The thread 0  executes i = 2
The thread 0  executes i = 3

[18584] signal (11.2): Segmentation fault: 11
in expression starting at none:0
zsh: segmentation fault  julia

I understand that julia 1.10 is brand new and could have some leftover bugs but just wondering if you'd have some pointer on where the issue could be coming from

Cheers

PS: the segfault disappears with a single thread (OMP_NUM_THREADS=1)

@mkitti
Copy link
Member

mkitti commented Jan 2, 2024

Could you provide the output of the following?

using Pkg
pkg"status"
pkg"status -m"

In particular, I am interested in the version of HDF5.jl and HDF5_jll.jl.

Do you get the same error if you just load HDF5_jll before hand?

Are you using a system libhdf5.dylib?

Do you experience the error with Julia 1.9.4?

Do you experience the error with Julia nightly builds?
https://julialang.org/downloads/nightlies/

@mkitti
Copy link
Member

mkitti commented Jan 2, 2024

Based on your demo, the main thing I would investigate are the __init__() functions for the HDF5.jl and the various submodules (Filters, API, Drivers).

My rough guess is that we're running into some trouble between Julia's task switching, (eager-)finalization, signals, and HDF5 being primarily single-threaded.

@mloubout
Copy link
Author

mloubout commented Jan 2, 2024

Pkg status:

julia> using Pkg

julia> pkg"status"
Status `~/.julia/environments/v1.10/Project.toml`
  [bccb42de] AutoTrader v0.1.0 `~/.julia/dev/AutoTrader`
  [23f7647f] CloudSegyIO v1.0.1 `~/.julia/dev/CloudSegyIO`
  [06ed14b1] Devito v0.11.2 `~/.julia/dev/Devito`
  [a52d0eb2] GradSampFWI v0.1.0 `~/.julia/dev/GradSampFWI`
  [f67ccb44] HDF5 v0.17.1
  [355d8124] ImageGather v0.2.7 `~/.julia/dev/ImageGather`
  [916415d5] Images v0.26.0
  [b7115f24] InvertibleNetworks v2.2.5 `~/.julia/dev/InvertibleNetworks`
  [42fd0dbc] IterativeSolvers v0.9.3
  [4138dd39] JLD v0.13.4
  [033835bb] JLD2 v0.4.40
  [bb331ad6] JOLI v0.8.5 `~/.julia/dev/JOLI`
  [f3b833dc] JUDI v3.3.9 `~/.julia/dev/JUDI`
  [32925ad8] JUDI4Cloud v1.0.0 `~/.julia/dev/JUDI4Cloud`
  [2f4a34ea] KirchMig v0.1.0 `~/.julia/dev/KirchMig`
  [7a12625a] LinearMaps v3.11.1 `~/.julia/dev/LinearMaps`
  [872c559c] NNlib v0.8.7 `~/.julia/dev/NNlib`
  [db9e0614] ParametricOperators v0.1.0 `~/.julia/dev/ParametricOperators`
  [86b14aa7] PhotoAcoustic v0.4.3 `~/.julia/dev/PhotoAcoustic`
  [438e738f] PyCall v1.96.4
  [d330b81b] PyPlot v2.11.2
  [157a0f19] SegyIO v0.8.3 `~/.julia/dev/SegyIO`
  [335f7d24] SetIntersectionProjection v0.2.4 `~/.julia/dev/SetIntersectionProjection`
  [e4c7bc62] SlimOptim v0.2.3 `~/.julia/dev/SlimOptim`
  [f6d04670] SlimPlotting v0.1.6 `~/.julia/dev/SlimPlotting`
  [aa149114] SourceEstimation v0.1.0 `~/.julia/dev/SourceEstimation`
  [cd417b76] TimeProbeSeismic v1.1.2 `~/.julia/dev/TimeProbeSeismic`
  [0d73aaa9] UNet v0.2.1 `~/.julia/dev/UNet`

julia> pkg"status -m"
Status `~/.julia/environments/v1.10/Manifest.toml`
  [fbe9abb3] AWS v1.90.3
⌅ [1c724243] AWSS3 v0.10.4
  [621f4979] AbstractFFTs v1.5.0
  [7f219486] AbstractNFFTs v0.8.2
  [14dbef02] AbstractStorage v1.1.0
  [7d9f7c33] Accessors v0.1.33
  [22286c92] AccurateArithmetic v0.3.8
⌅ [79e6a3ab] Adapt v3.7.2
  [dce04be8] ArgCheck v2.3.0
  [ec485272] ArnoldiMethod v0.2.0
⌅ [4fba245c] ArrayInterface v6.0.25
  [30b0a656] ArrayInterfaceCore v0.1.29
  [015c0d05] ArrayInterfaceOffsetArrays v0.1.7
  [b0d46f97] ArrayInterfaceStaticArrays v0.1.5
  [dd5226c6] ArrayInterfaceStaticArraysCore v0.1.4
  [31f734f8] ArrowTypes v2.3.0
  [bccb42de] AutoTrader v0.1.0 `~/.julia/dev/AutoTrader`
⌃ [13072b0f] AxisAlgorithms v1.0.1
  [39de3d68] AxisArrays v0.4.7
  [f239b30d] AzSessions v2.1.5
  [c6697862] AzStorage v2.4.1
  [0090f474] AzureClusterlessHPC v0.1.0
⌅ [ab4f0b2a] BFloat16s v0.2.0
  [fbb218c0] BSON v0.3.7
  [198e06fe] BangBang v0.3.39
  [9718e550] Baselet v0.1.1
  [26cce99e] BasicInterpolators v0.7.1
  [6e4b80f9] BenchmarkTools v1.4.0
  [d1d4a3ce] BitFlags v0.1.8
  [62783981] BitTwiddlingConvenienceFunctions v0.1.5
  [a74b3585] Blosc v0.7.3
⌅ [fa961155] CEnum v0.4.2
  [2a0fbf3d] CPUSummary v0.2.4
  [336ed68f] CSV v0.10.12
⌅ [052768ef] CUDA v3.13.1
  [49dc2e85] Calculus v0.5.1
  [aafaddc9] CatIndices v0.2.2
  [082447d4] ChainRules v1.58.1
  [d360d2e6] ChainRulesCore v1.19.0
⌃ [fb6a15b2] CloseOpenIntervals v0.1.11
  [23f7647f] CloudSegyIO v1.0.1 `~/.julia/dev/CloudSegyIO`
  [aaaa29a8] Clustering v0.15.6
  [523fee87] CodecBzip2 v0.8.1
  [944b1d66] CodecZlib v0.7.3
  [35d6a980] ColorSchemes v3.24.0
  [3da002f7] ColorTypes v0.11.4
  [c3611d14] ColorVectorSpace v0.10.0
  [5ae59095] Colors v0.12.10
  [861a8166] Combinatorics v1.0.2
  [bbf7d656] CommonSubexpressions v0.3.0
  [34da2185] Compat v4.10.1
  [a33af91c] CompositionsBase v0.1.2
  [ed09eef8] ComputationalResources v0.3.2
  [f0e56b4a] ConcurrentUtilities v2.3.0
  [8f4d0f93] Conda v1.10.0
  [187b0558] ConstructionBase v1.5.4
  [6add18c4] ContextVariablesX v0.1.3
  [150eb455] CoordinateTransformations v0.6.3
  [587fd27a] CovarianceEstimation v0.2.11
  [adafc99b] CpuId v0.3.1
  [a8cc5b0e] Crayons v4.1.1
  [dc8bdbbb] CustomUnitRanges v1.0.2
  [717857b8] DSP v0.7.9
  [9a962f9c] DataAPI v1.15.0
  [124859b0] DataDeps v0.7.11
  [a93c6f00] DataFrames v1.6.1
  [864edb3b] DataStructures v0.18.15
  [e2d170a0] DataValueInterfaces v1.0.0
  [244e2a9f] DefineSingletons v0.1.2
  [8bb1440f] DelimitedFiles v1.9.1
  [06ed14b1] Devito v0.11.2 `~/.julia/dev/Devito`
  [39dd38d3] Dierckx v0.5.3
  [163ba53b] DiffResults v1.1.0
  [b552c78f] DiffRules v1.15.1
  [b4f34e82] Distances v0.10.11
  [aaf54ef3] DistributedArrays v0.6.7
  [31c24e10] Distributions v0.25.104
  [ffbed154] DocStringExtensions v0.9.3
  [fa6b7ba4] DualNumbers v0.6.8
  [460bff9d] ExceptionUnwrapping v0.1.10
  [e2ba6199] ExprTools v0.1.10
  [8f5d6c58] EzXML v1.2.0
  [4f61f5a4] FFTViews v0.3.2
  [7a1cc6ca] FFTW v1.7.2
  [cc61a311] FLoops v0.2.1
  [b9860ae5] FLoopsBase v0.1.1
⌃ [7034ab61] FastBroadcast v0.2.4
  [5789e2e9] FileIO v1.16.1
  [48062228] FilePathsBase v0.9.21
  [1a297f60] FillArrays v1.9.3
⌃ [6a86dc24] FiniteDiff v2.17.0
  [53c48c17] FixedPointNumbers v0.8.4
⌅ [587475ba] Flux v0.13.4
  [9c68100b] FoldsThreads v0.1.2
  [f6369f11] ForwardDiff v0.10.36
  [b18b359b] FourierTools v0.4.2
  [069b7b12] FunctionWrappers v1.1.3
⌅ [d9f16b24] Functors v0.2.8
⌅ [0c68f7d7] GPUArrays v8.8.1
⌅ [46192b85] GPUArraysCore v0.1.5
⌅ [61eb1bfa] GPUCompiler v0.17.3
  [bc5e4493] GitHub v5.9.0
  [a52d0eb2] GradSampFWI v0.1.0 `~/.julia/dev/GradSampFWI`
  [f526b714] GraphViz v0.2.0
  [a2bd30eb] Graphics v1.1.2
  [86223c79] Graphs v1.9.0
  [c8ec2601] H5Zblosc v0.1.2
  [f67ccb44] HDF5 v0.17.1
  [cd3eb016] HTTP v1.10.1
  [2c695a8d] HistogramThresholding v0.3.1
  [3e5b6fbb] HostCPUFeatures v0.1.16
  [34004b35] HypergeometricFunctions v0.3.23
  [7869d1d1] IRTools v0.4.11
  [615f187c] IfElse v0.1.1
  [2803e5a7] ImageAxes v0.6.11
  [c817782e] ImageBase v0.1.7
  [cbc4b850] ImageBinarization v0.3.0
  [f332f351] ImageContrastAdjustment v0.3.12
  [a09fc81d] ImageCore v0.10.1
  [89d5987c] ImageCorners v0.1.3
  [51556ac3] ImageDistances v0.2.17
  [6a3955dd] ImageFiltering v0.7.8
  [355d8124] ImageGather v0.2.7 `~/.julia/dev/ImageGather`
  [82e4d734] ImageIO v0.6.7
  [6218d12a] ImageMagick v1.3.0
  [bc367c6b] ImageMetadata v0.9.9
  [787d08f9] ImageMorphology v0.4.5
  [2996bd0c] ImageQualityIndexes v0.3.7
  [80713f31] ImageSegmentation v1.8.2
  [4e3cecfd] ImageShow v0.3.8
  [02fcd773] ImageTransformations v0.10.0
  [916415d5] Images v0.26.0
  [f7bf1975] Impute v0.6.11
  [613c443e] IndexFunArrays v0.2.6
  [9b13fd28] IndirectArrays v1.0.0
  [d25df0c9] Inflate v0.1.4
  [83e8ac13] IniFile v0.5.1
  [22cec73e] InitialValues v0.3.1
  [842dd82b] InlineStrings v1.4.0
  [505f98c9] InplaceOps v0.3.0
  [18e54dd8] IntegerMathUtils v0.1.2
  [1d092043] IntegralArrays v0.1.5
⌅ [a98d9a8b] Interpolations v0.13.6
  [8197267c] IntervalSets v0.7.8
  [3587e190] InverseFunctions v0.1.12
  [41ab1584] InvertedIndices v1.3.0
  [b7115f24] InvertibleNetworks v2.2.5 `~/.julia/dev/InvertibleNetworks`
  [92d709cd] IrrationalConstants v0.2.2
  [c8e1da08] IterTools v1.9.0
  [42fd0dbc] IterativeSolvers v0.9.3
  [82899510] IteratorInterfaceExtensions v1.0.0
  [4138dd39] JLD v0.13.4
  [033835bb] JLD2 v0.4.40
  [692b3bcd] JLLWrappers v1.5.0
  [bb331ad6] JOLI v0.8.5 `~/.julia/dev/JOLI`
  [682c06a0] JSON v0.21.4
  [9b8beb19] JSONWebTokens v1.1.1
  [f3b833dc] JUDI v3.3.9 `~/.julia/dev/JUDI`
  [32925ad8] JUDI4Cloud v1.0.0 `~/.julia/dev/JUDI4Cloud`
  [b835a17e] JpegTurbo v0.1.5
  [b14d175d] JuliaVariables v0.2.4
  [8e2b3108] KahanSummation v0.3.1
  [2f4a34ea] KirchMig v0.1.0 `~/.julia/dev/KirchMig`
⌅ [929cbde3] LLVM v4.17.1
  [8ac3fa9e] LRUCache v1.6.0
  [b964fa9f] LaTeXStrings v1.3.1
⌃ [10f19ff3] LayoutPointers v0.1.13
  [8cdb02fc] LazyModules v0.3.1
  [d3d80556] LineSearches v7.2.0
  [7a12625a] LinearMaps v3.11.1 `~/.julia/dev/LinearMaps`
  [2ab3a3ac] LogExpFunctions v0.3.26
  [e6f89c97] LoggingExtras v1.0.3
⌃ [bdcacae8] LoopVectorization v0.12.150
  [d8e11817] MLStyle v0.4.17
⌅ [f1d291b0] MLUtils v0.2.11
⌃ [da04e1cc] MPI v0.20.16
  [3da0fdf6] MPIPreferences v0.1.10
  [1914dd2f] MacroTools v0.5.12
  [d125e4d3] ManualMemory v0.1.8
  [dbb5928d] MappedArrays v0.4.2
  [7eb4fadd] Match v2.0.0
⌃ [b8f27783] MathOptInterface v1.23.0
  [739be429] MbedTLS v1.1.9
  [c03570c3] Memoize v0.4.4
  [626554b9] MetaGraphs v0.7.2
  [128add7d] MicroCollections v0.1.4
  [e1d29d7a] Missings v1.1.0
  [78c3b35d] Mocking v0.7.7
  [e94cdb99] MosaicViews v0.3.4
  [d8a4904e] MutableArithmetics v1.4.0
  [98581153] NDTools v0.5.3
  [efe261a4] NFFT v0.13.3
  [d41bc354] NLSolversBase v7.8.3
  [872c559c] NNlib v0.8.7 `~/.julia/dev/NNlib`
⌃ [a00861dc] NNlibCUDA v0.2.3
  [77ba4419] NaNMath v1.0.2
  [71a1bf82] NameResolution v0.1.5
  [356022a1] NamedDims v1.2.1
  [b8a86587] NearestNeighbors v0.4.16
  [f09324ee] Netpbm v1.1.1
  [4d1e1d77] Nullables v1.0.0
  [ab2f91bb] OSQP v0.8.0
  [6fe1bfb0] OffsetArrays v1.13.0
  [52e1d378] OpenEXR v0.3.2
  [4d8831e6] OpenSSL v1.4.1
⌅ [3bd65402] Optimisers v0.2.9
  [bac558e1] OrderedCollections v1.6.3
  [90014a1f] PDMats v0.11.31
  [f57f5aa1] PNGFiles v0.4.3
  [5432bcbf] PaddedViews v0.5.12
  [d96e819e] Parameters v0.12.3
  [db9e0614] ParametricOperators v0.1.0 `~/.julia/dev/ParametricOperators`
  [69de0a69] Parsers v2.8.1
  [86b14aa7] PhotoAcoustic v0.4.3 `~/.julia/dev/PhotoAcoustic`
  [eebad327] PkgVersion v0.3.3
⌃ [f517fe37] Polyester v0.7.2
  [1d0040c9] PolyesterWeave v0.2.1
⌅ [f27b6e38] Polynomials v3.2.13
  [2dfb63ee] PooledArrays v1.4.3
  [aea7be01] PrecompileTools v1.2.0
  [21216c6a] Preferences v1.4.1
  [8162dcfd] PrettyPrint v0.2.0
  [08abe8d2] PrettyTables v2.3.1
  [27ebfcd6] Primes v0.5.5
  [33c8b6b6] ProgressLogging v0.1.4
  [92933f4c] ProgressMeter v1.9.0
  [438e738f] PyCall v1.96.4
  [d330b81b] PyPlot v2.11.2
  [4b34888f] QOI v1.0.0
  [1fd47b50] QuadGK v2.9.1
  [94ee1d12] Quaternions v0.7.5
  [74087812] Random123 v1.6.2
  [e6cf234a] RandomNumbers v1.5.3
  [b3c3ace0] RangeArrays v0.3.2
  [c84ed2f1] Ratios v0.4.5
  [c1ae055f] RealDot v0.1.0
  [3cdcf5f2] RecipesBase v1.3.4
  [189a3867] Reexport v1.2.2
  [dee08c22] RegionTrees v0.3.2
  [ae029012] Requires v1.3.0
  [20febd7b] Retry v0.4.1
  [79098fc4] Rmath v0.7.1
  [b0e4dd01] RollingFunctions v0.8.0
  [6038ab10] Rotations v1.6.1
  [94e857df] SIMDTypes v0.1.0
  [476501e8] SLEEFPirates v0.6.42
  [157a0f19] SegyIO v0.8.3 `~/.julia/dev/SegyIO`
  [91c51154] SentinelArrays v1.4.1
  [335f7d24] SetIntersectionProjection v0.2.4 `~/.julia/dev/SetIntersectionProjection`
  [efcf1570] Setfield v1.1.1
  [1277b4bf] ShiftedArrays v2.0.0
  [605ecd9f] ShowCases v0.1.0
  [777ac1f9] SimpleBufferStream v1.1.0
  [699a6c99] SimpleTraits v0.9.4
  [47aef6b3] SimpleWeightedGraphs v1.4.0
  [45858cf5] Sixel v0.1.3
  [e4c7bc62] SlimOptim v0.2.3 `~/.julia/dev/SlimOptim`
  [f6d04670] SlimPlotting v0.1.6 `~/.julia/dev/SlimPlotting`
  [66db9d55] SnoopPrecompile v1.0.3
  [2133526b] SodiumSeal v0.1.1
  [a2af1166] SortingAlgorithms v1.2.1
  [aa149114] SourceEstimation v0.1.0 `~/.julia/dev/SourceEstimation`
  [dc90abb0] SparseInverseSubset v0.1.2
  [276daf66] SpecialFunctions v2.3.1
  [171d559e] SplittablesBase v0.1.15
  [cae243ae] StackViews v0.1.1
  [aedffcd0] Static v0.8.8
  [90137ffa] StaticArrays v1.8.2
  [1e83bf80] StaticArraysCore v1.4.2
  [82ae8749] StatsAPI v1.7.0
⌅ [2913bbd2] StatsBase v0.33.21
  [4c63d2b9] StatsFuns v1.3.0
⌅ [7792a7ef] StrideArraysCore v0.4.7
⌅ [5e0ebb24] Strided v1.2.3
  [892a3eda] StringManipulation v0.3.4
  [09ab397b] StructArrays v0.6.16
  [2da68c74] SymDict v0.3.0
  [a4af3ec5] SyntaxTree v1.0.1
  [ab02a1b2] TableOperations v1.2.0
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.11.1
  [62fd8b95] TensorCore v0.1.1
  [8290d209] ThreadingUtilities v0.5.2
⌅ [731e570b] TiffImages v0.6.8
⌃ [06e1c1a7] TiledIteration v0.4.2
  [cd417b76] TimeProbeSeismic v1.1.2 `~/.julia/dev/TimeProbeSeismic`
  [a759f4b9] TimerOutputs v0.5.23
  [c751599d] ToeplitzMatrices v0.8.2
  [3bb67fe8] TranscodingStreams v0.10.2
  [28d57a85] Transducers v0.4.79
  [9d95972d] TupleTools v1.4.3
  [0d73aaa9] UNet v0.2.1 `~/.julia/dev/UNet`
  [5c2747f8] URIs v1.5.1
  [3a884ed6] UnPack v1.0.2
⌃ [3d5dd08c] VectorizationBase v0.21.58
  [81def892] VersionParsing v1.3.0
⌅ [29a6e085] Wavelets v0.9.5
  [ea10d353] WeakRefStrings v1.4.2
⌅ [efce3f68] WoodburyMatrices v0.5.6
  [76eceee3] WorkerUtilities v1.6.1
  [72c71f33] XML v0.3.2
  [228000da] XMLDict v0.4.1
  [e88e6eb3] Zygote v0.6.68
  [700de1a5] ZygoteRules v0.2.4
  [00c928b4] AzStorage_jll v0.9.0+0
  [0b7ba130] Blosc_jll v1.21.5+0
  [6e34b625] Bzip2_jll v1.0.8+0
  [83423d85] Cairo_jll v1.16.1+1
  [cd4c43a9] Dierckx_jll v0.1.0+0
  [2e619515] Expat_jll v2.5.0+0
  [f5851436] FFTW_jll v3.3.10+0
  [a3f928ae] Fontconfig_jll v2.13.93+0
  [d7e528f0] FreeType2_jll v2.13.1+0
  [559328eb] FriBidi_jll v1.0.10+0
  [78b55507] Gettext_jll v0.21.0+0
  [7746bdde] Glib_jll v2.76.5+0
  [3b182d85] Graphite2_jll v1.3.14+0
  [3c863552] Graphviz_jll v2.50.0+1
  [0234f1f7] HDF5_jll v1.14.2+1
  [2e76f6c2] HarfBuzz_jll v2.8.1+1
  [e33a78d0] Hwloc_jll v2.10.0+0
⌅ [c73af94c] ImageMagick_jll v6.9.10-12+3
  [905a6f67] Imath_jll v3.1.7+0
  [1d5cc7b8] IntelOpenMP_jll v2024.0.2+0
  [aacddb02] JpegTurbo_jll v3.0.1+0
  [88015f11] LERC_jll v3.0.0+1
⌅ [dad2f222] LLVMExtra_jll v0.0.18+0
  [1d63c593] LLVMOpenMP_jll v15.0.7+0
  [dd4b983a] LZO_jll v2.10.1+0
⌅ [e9f186c6] Libffi_jll v3.2.2+1
  [d4300ac3] Libgcrypt_jll v1.8.7+0
  [7add5ba3] Libgpg_error_jll v1.42.0+0
  [94ce4f54] Libiconv_jll v1.17.0+0
  [4b2f31a3] Libmount_jll v2.35.0+0
⌅ [89763e89] Libtiff_jll v4.4.0+0
  [38a345b3] Libuuid_jll v2.36.0+0
  [5ced341a] Lz4_jll v1.9.4+0
  [856f044c] MKL_jll v2024.0.0+0
  [7cb0a576] MPICH_jll v4.1.2+1
  [f1f71cc9] MPItrampoline_jll v5.3.1+1
  [9237b28f] MicrosoftMPI_jll v10.1.4+1
  [9c4f68bf] OSQP_jll v0.600.200+0
  [18a262bb] OpenEXR_jll v3.1.4+0
  [fe0851c0] OpenMPI_jll v5.0.1+0
  [458c3c95] OpenSSL_jll v3.0.12+0
  [efe28fd5] OpenSpecFun_jll v0.5.5+0
  [32165bc3] PMIx_jll v4.2.7+0
  [36c8627f] Pango_jll v1.50.14+0
  [30392449] Pixman_jll v0.42.2+0
  [f50d1b31] Rmath_jll v0.4.0+0
  [02c8fc9c] XML2_jll v2.12.2+0
  [aed1982a] XSLT_jll v1.1.34+0
  [4f6342f7] Xorg_libX11_jll v1.8.6+0
  [0c0b7dd1] Xorg_libXau_jll v1.0.11+0
  [a3789734] Xorg_libXdmcp_jll v1.1.4+0
  [1082639a] Xorg_libXext_jll v1.3.4+4
  [ea2f1a96] Xorg_libXrender_jll v0.9.10+4
  [14d82f49] Xorg_libpthread_stubs_jll v0.1.1+0
  [c7cfdc94] Xorg_libxcb_jll v1.15.0+0
  [c5fb5394] Xorg_xtrans_jll v1.5.0+0
  [3161d3a3] Zstd_jll v1.5.5+0
  [477f73a3] libaec_jll v1.0.6+1
  [1080aeaf] libevent_jll v2.1.13+1
  [b53b4c65] libpng_jll v1.6.40+0
  [075b6546] libsixel_jll v1.10.3+0
  [a9144af2] libsodium_jll v1.0.20+0
  [eb928a42] prrte_jll v3.0.2+0
  [0dad84c5] ArgTools v1.1.1
  [56f22d72] Artifacts
  [2a0f44e3] Base64
  [ade2ca70] Dates
  [8ba89e20] Distributed
  [f43a241f] Downloads v1.6.0
  [7b1f6079] FileWatching
  [9fa8497b] Future
  [b77e0a4c] InteractiveUtils
  [4af54fe1] LazyArtifacts
  [b27032c2] LibCURL v0.6.4
  [76f85450] LibGit2
  [8f399da3] Libdl
  [37e2e46d] LinearAlgebra
  [56ddb016] Logging
  [d6f4376e] Markdown
  [a63ad114] Mmap
  [ca575930] NetworkOptions v1.2.0
  [44cfe95a] Pkg v1.10.0
  [de0858da] Printf
  [9abbd945] Profile
  [3fa0cd96] REPL
  [9a3f8284] Random
  [ea8e919c] SHA v0.7.0
  [9e88b42a] Serialization
  [1a1011a3] SharedArrays
  [6462fe0b] Sockets
  [2f01184e] SparseArrays v1.10.0
  [10745b16] Statistics v1.10.0
  [4607b0f0] SuiteSparse
  [fa267f1f] TOML v1.0.3
  [a4e569a6] Tar v1.10.0
  [8dfed614] Test
  [cf7118a7] UUIDs
  [4ec0a83e] Unicode
  [e66e0078] CompilerSupportLibraries_jll v1.0.5+1
  [deac9b47] LibCURL_jll v8.4.0+0
  [e37daf67] LibGit2_jll v1.6.4+0
  [29816b5a] LibSSH2_jll v1.11.0+1
  [c8ffd9c3] MbedTLS_jll v2.28.2+1
  [14a3606d] MozillaCACerts_jll v2023.1.10
  [4536629a] OpenBLAS_jll v0.3.23+2
  [05823500] OpenLibm_jll v0.8.1+2
  [efcefdf7] PCRE2_jll v10.42.0+1
  [bea87d4a] SuiteSparse_jll v7.2.1+1
  [83775a58] Zlib_jll v1.2.13+1
  [8e850b90] libblastrampoline_jll v5.8.0+1
  [8e850ede] nghttp2_jll v1.52.0+1
  [3f19e933] p7zip_jll v17.4.0+2
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`

Do you get the same error if you just load HDF5_jll before hand?

Yes, and with HDF5_jll onoy as well so probably the source of the issue.

Are you using a system libhdf5.dylib?

Not that I know of

Do you experience the error with Julia 1.9.4?

no

Do you experience the error with Julia nightly builds?

I haven't try I'll see if I can

@mloubout
Copy link
Author

mloubout commented Jan 2, 2024

Are you using a system libhdf5.dylib?

So I installed a system one to check (brew install hdf5-mpi) and using the system one does not error so my assumption is that the library in HDF5_jll is somehow creating issues with 1.10

@simonbyrne
Copy link
Collaborator

@mloubout can you try it without -ffast-math?

@mloubout
Copy link
Author

mloubout commented Jan 2, 2024

can you try it without -ffast-math?

segfaults as well

@simonbyrne
Copy link
Collaborator

Okay, I can reproduce it. It appears to work if I first

using Libdl
dlopen("/opt/homebrew/opt/llvm/lib/libomp.dylib")

Which suggests that hdf5 or one of its dependencies is pulling in a different libomp.

@simonbyrne
Copy link
Collaborator

Ah, that's the issue: HDF5_jll depends on LLVMOpenMP_jll, which loads its own libomp.dylib (I'm not sure why, since it isn't actually linked into libhdf5?)

@simonbyrne
Copy link
Collaborator

@eschnett do you know why LLVMOpenMP_jll is a dependency? It looks like it was added in JuliaPackaging/Yggdrasil#6551

@mloubout
Copy link
Author

mloubout commented Jan 2, 2024

Sweet thanks for finding the source of it

@mkitti
Copy link
Member

mkitti commented Jan 2, 2024

This suggests that trying earlier versions of HDF5_jll may resolve the issue, particularly 1.12.2.

I think the most productive approach to addressing this going forward would be to package libhdf5 1.14.3.

https://raw.githubusercontent.com/HDFGroup/hdf5/hdf5_1_14_3/release_docs/RELEASE.txt

Critically, we may not need those settings files since this has now been merged into the main release branch.

- Running H5detect is no longer required for cross-compiling

  The functionality of H5detect is now exercised at library startup,
  so H5detect has been removed.

@mloubout
Copy link
Author

mloubout commented Jan 2, 2024

Downgrading to 1.12.2 seems to work indeed, I'll have to temporarily disable some autoupdate on my system so that it doesn't revert to 1.14.2 and I'll keep an eye out for the next release

@mkitti
Copy link
Member

mkitti commented Jan 2, 2024

You might want to use Pkg.pin.

(@v1.10) pkg> ?pin
  pin pkg[=uuid] ...
  pin [--all]

  Pin packages to given versions, or the current version if no
  version is specified. A pinned package has its version fixed and
  will not be upgraded or downgraded. A pinned package has the
  symbol ⚲ next to its version in the status list.. Specifying --all
  will pin all dependencies (direct and indirect).

  Examples

  pkg> pin Example
  pkg> pin Example@0.5.0
  pkg> pin Example=7876af07-990d-54b4-ab0e-23690620f79a@0.5.0
  pkg> pin --all

@mkitti mkitti changed the title HDF5.jl triggers segfault in cccal with openmp+clang(m1) with julia 1.10 HDF5.jl triggers segfault in ccall with openmp+clang(m1) with julia 1.10 Jan 3, 2024
@mkitti
Copy link
Member

mkitti commented Jan 4, 2024

Just to confirm, there is no point for OpenMP to be there, right? Maybe he confused OpenMP and OpenMPI?

@giordano
Copy link
Member

giordano commented Jan 5, 2024

Removing LLVMOpenMP from the dependencies of HDF5 will not change that the fact that if some other libraries load LLVMOpenMP you get into the same problem. You may have more luck by overriding libomp from LLVMOpenMP to point to your system libomp: https://docs.binarybuilder.org/stable/jll/#Overriding-specific-products

@mkitti
Copy link
Member

mkitti commented Jan 5, 2024

True. Still, I cannot fathom why OpenMP is there. The HDF5 libraries have no direct dependence on OpenMP.

@giordano
Copy link
Member

giordano commented Jan 5, 2024

Still, I cannot fathom why OpenMP is there. The HDF5 libraries have no direct dependence on OpenMP.

Some build logs do mention openmp, but it isn't clear to me what's being used for. But not in the macos build log I looked at, in that one there was no mention of openmp at all.

@eschnett
Copy link
Contributor

eschnett commented Jan 6, 2024

@simonbyrne I don't recall why I added LLVMOpenMP_jll. Maybe I thought it was necessary to enable multi-threading in HDF5, although this seems to be based on pthreads. If there is no build failure then we should leave it out.

@mkitti
Copy link
Member

mkitti commented Jan 8, 2024

@mloubout could you please update. HDF5_jll.jl 1.14.3 has now been released. It no longer carries an OpenMP dependency and thus should no interfere with your use of OpenMP. That said you might want to still consider using LLVMOpenMP from Julia's binary distribution channels:

https://github.com/JuliaBinaryWrappers/LLVMOpenMP_jll.jl
https://github.com/JuliaBinaryWrappers/Clang_jll.jl

@mloubout
Copy link
Author

mloubout commented Jan 10, 2024

could you please update. HDF5_jll.jl 1.14.3 has now been released

Just tried it and all good, thanks a lot.

That said you might want to still consider using LLVMOpenMP from Julia's binary distribution channels:

That's not really an option in my case, while I use my framework (devito) from julia, I rely heavily on a full compiler setup which on Mx-osx is the latest llvm (17 in my case) and related libraries. And since it's a JIT framework I can't expect it to try to figure out if Julia is here and where libraries are since in general it would not interact with julia at all.

I think long term for stability my best solution would indeed be to use Preferences so that if any package uses llvmopenmp it will use my system one.

Thanks for all the help

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

5 participants