[Embedding] Initialization of nthreads_per_pool when jl_options.nthreads == 1
Here is the unsafe access to the variable that causes segfaults: https://github.com/JuliaLang/julia/blob/d6294ba973db1dea9dc932779008fd66d27c4bd2/src/threading.c#L726-L727
By default jl_options is initalized with zeros, and if only nthreads is set this will cause the segfault.
This is not very convenient for the end user, also my use case is setting nthreads = 1 because I am using handle_signals = 0 which caused me segfaults in multi-threaded environment for a different reason (GC behavior).
Note that handle_signals=0 is an unsupported option, and its use is discouraged (x-ref: #50278 #58464)
Can you expand a bit more on your use-case and how are you triggering this?
I am embedding Julia (I am compiling code into .so using trim) in our software, I have two restrictions:
1 - I can't use more than 1 thread (system requirement)
2 - In the system there is already signal handler, and faik at this moment there is no means to have a cooperative signal handling with Julia.
That's why I am disabling signal handler and limiting number of threads to 1.
In essence my bug report is only about correlation between nthreads and nthreads_per_pool which is not obvious if you don't look into the code.
So your issue is similar to https://github.com/JuliaLang/julia/blob/8567a3a10f4b746b91bf406bfe3171c3399aed8d/test/gcext/gcext.c#L608
Where this data-structure is manually initialized. Yeah that should be fixed.