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

caml_callback2 crashes on aarch64 #6489

Closed
vicuna opened this issue Jul 15, 2014 · 4 comments
Closed

caml_callback2 crashes on aarch64 #6489

vicuna opened this issue Jul 15, 2014 · 4 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Jul 15, 2014

Original bug ID: 6489
Reporter: Richard Jones
Assigned to: @mshinwell
Status: closed (set by @xavierleroy on 2015-12-11T18:28:12Z)
Resolution: fixed
Priority: normal
Severity: crash
Version: 4.02.0+beta1 / +rc1
Fixed in version: 4.02.0+dev
Category: back end (clambda to assembly)

Bug description

caml_callback2 segfaults when called, on aarch64.

Steps to reproduce

Compile the attached program using:

ocamlopt.opt callback.c callback_ml.ml -o callback

Then run it using:

./callback

The output is:

$ ./callback
f1 (100)
Segmentation fault

Note that caml_callback and caml_callback3 are fine, it's just caml_callback2 which fails.

File attachments

@vicuna
Copy link
Author

vicuna commented Jul 15, 2014

Comment author: Richard Jones

Well, that's not quite true. All of the caml_callback* functions cause heap corruption. If you call Gc.compact () after any of them, then it will segfault. Only caml_callback2 segfaults on its own without any help.

@vicuna
Copy link
Author

vicuna commented Jul 15, 2014

Comment author: Richard Jones

Please ignore the previous comment, as I made a mistake in my test. Only caml_callback2 is problematic.

@vicuna
Copy link
Author

vicuna commented Jul 15, 2014

Comment author: Richard Jones

This is caused by a missing close comment */ here:

https://github.com/ocaml/ocaml/blob/4.02/asmrun/arm64.S#L481

The fix is:

--- a/asmrun/arm64.S
+++ b/asmrun/arm64.S
@@ -478,7 +478,7 @@ caml_callback2_exn:
/* Initial shuffling of arguments (x0 = closure, x1 = arg1, x2 = arg2) /
mov TMP, x0
mov x0, x1 /
x0 = first arg */

  •    mov     x1, x2          /* x1 = second arg
    
  •    mov     x1, x2          /* x1 = second arg */
       mov     x2, TMP         /* x2 = closure environment */
       ADDRGLOBAL(ARG, caml_apply2)
       b       .Ljump_to_caml
    

@vicuna
Copy link
Author

vicuna commented Jul 16, 2014

Comment author: @mshinwell

Very good. Thanks for the fix. Committed to 4.02 and trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants