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

Linking with Ssl causes segfault on multicore OCaml #76

Closed
talex5 opened this issue Jan 11, 2022 · 2 comments
Closed

Linking with Ssl causes segfault on multicore OCaml #76

talex5 opened this issue Jan 11, 2022 · 2 comments

Comments

@talex5
Copy link

talex5 commented Jan 11, 2022

I've been investigating why Dream segfaults when run on multicore (see aantron/dream#191).

I've managed to simplify the test-case to this (with ssl as its only dependency):

let foo = Ssl.file_descr_of_socket

let () =
  while true do
    Gc.full_major ()
  done

This segfaults immediately for me when run under ocaml-variants.4.12.0+domains.

I believe the cause is this bit of ssl.ml:

ocaml-ssl/src/ssl.ml

Lines 191 to 193 in b711cd4

external get_client_verify_callback_ptr : unit -> verify_callback = "ocaml_ssl_get_client_verify_callback_ptr"
let client_verify_callback = get_client_verify_callback_ptr ()

The C stub is

ocaml-ssl/src/ssl_stubs.c

Lines 562 to 565 in b711cd4

CAMLprim value ocaml_ssl_get_client_verify_callback_ptr(value unit)
{
return (value)client_verify_callback;
}

However, client_verify_callback is not an OCaml value, it's a C function. This causes the GC to crash when trying to mark it.

talex5 added a commit to talex5/dream that referenced this issue Jan 18, 2022
It segfaults under multicore: see savonet/ocaml-ssl#76
talex5 added a commit to talex5/dream that referenced this issue Jan 20, 2022
It segfaults under multicore: see savonet/ocaml-ssl#76
talex5 added a commit to talex5/dream that referenced this issue Feb 10, 2022
patricoferris pushed a commit to patricoferris/dream that referenced this issue Feb 11, 2022
It segfaults under multicore: see savonet/ocaml-ssl#76
patricoferris pushed a commit to patricoferris/dream that referenced this issue Feb 11, 2022
@patricoferris
Copy link

I just bumped into this over at https://github.com/patricoferris/dream-multicore-repro

@anmonteiro
Copy link
Collaborator

This should have been fixed in #83 and released in 0.5.11.

Willenbrink pushed a commit to Willenbrink/dream that referenced this issue Mar 13, 2023
Willenbrink pushed a commit to Willenbrink/dream that referenced this issue Mar 13, 2023
Willenbrink pushed a commit to Willenbrink/dream that referenced this issue Apr 2, 2023
Willenbrink pushed a commit to Willenbrink/dream that referenced this issue Apr 3, 2023
It segfaults under multicore: see savonet/ocaml-ssl#76
Willenbrink pushed a commit to Willenbrink/dream that referenced this issue Apr 3, 2023
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

Successfully merging a pull request may close this issue.

3 participants