julia icon indicating copy to clipboard operation
julia copied to clipboard

Call `pthread_attr_init` in `jl_init_stack_limits`

Open ararslan opened this issue 1 year ago • 5 comments

#55515 seems to have introduced segfaults on FreeBSD during the atexit and ccall tests. Prior to that PR, we had been calling pthread_attr_init in jl_init_stack_limits on FreeBSD. According to the manual page for pthread_attr_get_np, it is "HIGHLY RECOMMENDED" to use pthread_attr_init to allocate storage. Might as well put it back then, and hopefully it'll fix the segfaults.

ararslan avatar Aug 27 '24 04:08 ararslan

Looks like this indeed fixes the atexit segfaults on FreeBSD. The CI failures for the build on musl Linux and tests for Linux PowerPC, AArch64, and x86_64 with assertions are unrelated.

ararslan avatar Aug 27 '24 16:08 ararslan

I don't know, should it? Doesn't seem to be required on Linux though it shouldn't hurt to call it.

ararslan avatar Aug 27 '24 23:08 ararslan

It may cause a memory leak, since it fails to get destroyed

vtjnash avatar Aug 27 '24 23:08 vtjnash

Doesn't it get destroyed here? https://github.com/JuliaLang/julia/blob/7d2a7de5839f3461bcb3b9f131f384f7fc041da5/src/init.c#L78

ararslan avatar Aug 27 '24 23:08 ararslan

The second does, but not the first

vtjnash avatar Aug 28 '24 01:08 vtjnash

I don't understand, I only see one pthread_attr_t being created in this function, line 68: https://github.com/JuliaLang/julia/blob/7d2a7de5839f3461bcb3b9f131f384f7fc041da5/src/init.c#L50-L101

ararslan avatar Aug 28 '24 15:08 ararslan

I still don't get why it shouldn't be called on Linux, but at any rate, I've moved the call to be FreeBSD only.

ararslan avatar Aug 28 '24 21:08 ararslan

Quoth Jameson in Slack, "just merge." Okie dokie

ararslan avatar Aug 30 '24 17:08 ararslan