Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006489OCamlOCaml backend (code generation)public2014-07-15 21:462014-07-16 08:36
ReporterRichard Jones 
Assigned Toshinwell 
PrioritynormalSeveritycrashReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.02.0+beta1 / +rc1 
Target VersionFixed in Version4.02.0+dev 
Summary0006489: caml_callback2 crashes on aarch64
Descriptioncaml_callback2 segfaults when called, on aarch64.
Steps To ReproduceCompile 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.
TagsNo tags attached.
Attached Filesc file icon callback.c [^] (461 bytes) 2014-07-15 21:46 [Show Content]
? file icon callback_ml.ml [^] (233 bytes) 2014-07-15 21:47 [Show Content]

- Relationships

-  Notes
(0011827)
Richard Jones (reporter)
2014-07-15 21:49

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.
(0011828)
Richard Jones (reporter)
2014-07-15 23:28

Please ignore the previous comment, as I made a mistake in my test. Only caml_callback2 is problematic.
(0011829)
Richard Jones (reporter)
2014-07-15 23:32

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
(0011830)
shinwell (developer)
2014-07-16 08:36

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

- Issue History
Date Modified Username Field Change
2014-07-15 21:46 Richard Jones New Issue
2014-07-15 21:46 Richard Jones File Added: callback.c
2014-07-15 21:47 Richard Jones File Added: callback_ml.ml
2014-07-15 21:49 Richard Jones Note Added: 0011827
2014-07-15 23:28 Richard Jones Note Added: 0011828
2014-07-15 23:32 Richard Jones Note Added: 0011829
2014-07-16 08:36 shinwell Note Added: 0011830
2014-07-16 08:36 shinwell Status new => resolved
2014-07-16 08:36 shinwell Fixed in Version => 4.02.0+dev
2014-07-16 08:36 shinwell Resolution open => fixed
2014-07-16 08:36 shinwell Assigned To => shinwell


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker