You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 3838 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi,
it seems that variables named "err" and "error" are badly handled by the
dynamic linker. Compiling in static mode the following code gives the
expected result, i.e. consecutive adresses:
--8<------ x.c ---------------------------------------
#include <stdio.h>
#include <caml/mlvalues.h>
#include <caml/memory.h>
Original bug ID: 3838
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi,
it seems that variables named "err" and "error" are badly handled by the
dynamic linker. Compiling in static mode the following code gives the
expected result, i.e. consecutive adresses:
--8<------ x.c ---------------------------------------
#include <stdio.h>
#include <caml/mlvalues.h>
#include <caml/memory.h>
float a, b, err, error, c;
value f(value _) {
printf("&a=%x\n",&a);
printf("&b=%x\n",&b);
printf("&err=%x\n",&err);
printf("&error=%x\n",&error);
printf("&c=%x\n",&c);
return Val_unit;
}
--8<---------------------------------------------
However, addresses of "err" and "error" are wrong if I use dynamic
linking (and it ends in a seg fault If you try to assign them):
pascal@magimix:tmp% ocamlc x.c
pascal@magimix:tmp% touch empty.ml
pascal@magimix:tmp% ocamlmklib -o l x.o empty.ml
pascal@magimix:tmp% ocaml l.cma
Objective Caml version 3.08.3
external f : unit -> unit = "f";;
external f : unit -> unit = "f"
f();;
&a=4032c9e0
&b=4032c9d0
&err=40170c90
&error=40170e60
&c=4032c9d4
This is on a stable Debian GNU/Linux sarge running a 2.6.8 kernel
Some checks are missing during linking ?
--Pascal
The text was updated successfully, but these errors were encountered: