Skip to content

Segfault in Weak.get_copy with Infix_tag #9485

@stedolan

Description

@stedolan

The implementation of Weak.get_copy is missing the special case necessary to handle Infix_tag, so it can corrupt memory:

        OCaml version 4.10.0

# let w = Weak.create 1 in
  let rec f () = g () and g () = f () in
  Weak.set w 0 (Some g);
  match Weak.get_copy w 0 with Some h -> h () | _ -> ();;
Segmentation fault

I don't think this is particularly urgent to fix, because it's been there a long time without anyone noticing:

        Objective Caml version 3.10.2

# let w = Weak.create 1 in
  let rec f () = g () and g () = f () in
  Weak.set w 0 (Some g);
  match Weak.get_copy w 0 with Some h -> h () | _ -> ();;        
Segmentation fault

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions