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: 4068 Reporter:@mmottl Status: closed (set by @damiendoligez on 2006-07-25T09:02:18Z) Resolution: fixed Priority: normal Severity: minor Version: 3.08.4 Category: ~DO NOT USE (was: OCaml general) Monitored by: smimram @mmottl
This means that "result", which may be an expression, is evaluated outside of the protected block. I have already seen several instances where people who didn't know about this subtlety wrote something like e.g. "CAMLreturn(caml_copy_string(x))", where "x" is part of an object protected by the CAMLparam/return block. This may, of course, lead to segfaults if the string allocation triggers the GC.
The following definition would prevent people from making this common mistake:
Original bug ID: 4068
Reporter: @mmottl
Status: closed (set by @damiendoligez on 2006-07-25T09:02:18Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.08.4
Category: ~DO NOT USE (was: OCaml general)
Monitored by: smimram @mmottl
Bug description
The definition of CAMLreturn is:
#define CAMLreturn(result) do{
caml_local_roots = caml__frame;
return (result);
}while(0)
This means that "result", which may be an expression, is evaluated outside of the protected block. I have already seen several instances where people who didn't know about this subtlety wrote something like e.g. "CAMLreturn(caml_copy_string(x))", where "x" is part of an object protected by the CAMLparam/return block. This may, of course, lead to segfaults if the string allocation triggers the GC.
The following definition would prevent people from making this common mistake:
#define CAMLreturn(result) do{
value v_res = (result);
caml_local_roots = caml__frame;
return v_res;
}while(0)
The C-compiler will optimize away assignments of values anyway.
The text was updated successfully, but these errors were encountered: