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

Bug 3.080 Module Obj / Obj.c #2946

Closed
vicuna opened this issue Jul 15, 2004 · 2 comments
Closed

Bug 3.080 Module Obj / Obj.c #2946

vicuna opened this issue Jul 15, 2004 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 15, 2004

Original bug ID: 2946
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Yoann Fabre
Version: 3.08 Alpha2
OS: Win2000 SP4 + Cygwin
Submission from: nas-p19-3-62-147-34-225.dial.proxad.net (62.147.34.225)

Bonjour,

Voici donc le bug de Obj.tag :

let u = Obj.repr [| |];;

val u : Obj.t =

size u;;

  • : int = 0

tag u;;

  • : int = 500

is_block u;;

  • : bool = true

Cause du bug :

-- obj.c --

CAMLprim value caml_obj_tag(value arg)
{
if (Is_long (arg)){
return 1000;
}else if (Is_young (arg) || Is_in_heap (arg)){
return Val_int(Tag_val(arg));
}else{
return 1001;
}
}

Le cas Is_atom(arg) N'EST PAS géré !!!

Autre bug :

On a dans Obj.ml les constantes suivantes :

Obj.out_of_heap_tag;;

  • : int = 1001

Obj.int_tag;;

  • : int = 1000

Ce qui bien sur ne convient pas a cause de
l'absence de Val_int(...) dans les deux
return concernés de caml_obj_tag.

Exemple :

Obj.tag (Obj.repr 42);;

  • : int = 500

Mon avis sur la question :-)

En rajontant ces cas, caml_obj_tag
devient IMHO /trop/ couteuse ! Pourquoi
proteger des fonctions de Obj.ml des seg
fault ? Le "but" de ce module est d'etre
unsafe, non ?

ON NE DEVRAIT PAS POUVOIR ECRIRE :

Obj.tag (Obj.repr 42);;

MAIS ON DEVRAIT ECRIRE :

let safe_tag v = if is_block v then tag v else ...

Retournons donc au bon vieux :

CAMLprim value caml_obj_tag(value arg)
{
return Val_int(Tag_val(arg));
}

Nota Bene : j'ai besoin de ce type de fonction
car j'ecris un interpret en Ocaml pour la phase
de prototypage.

Cordialement,
Yoann

@vicuna
Copy link
Author

vicuna commented Aug 6, 2004

Comment author: administrator

Bonjour,

Full_Name: Yoann Fabre
Version: 3.08 Alpha2

Voici donc le bug de Obj.tag :

Merci pour le rapport de bug. J'ai fixe ce bug dans la version de travail.

MAIS ON DEVRAIT ECRIRE :

let safe_tag v = if is_block v then tag v else ...

C'est trop casse-gueule car le "is_block v" peut devenir faux lors d'un GC.
Il est bien plus sur (et pas si couteux) d'avoir un Obj.tag atomique.

-- Damien

@vicuna
Copy link
Author

vicuna commented Aug 6, 2004

Comment author: administrator

fixed DD 2004-07-16

@vicuna vicuna closed this as completed Aug 6, 2004
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant