Skip to content

Structs with string fields get corrupted #19

@talex5

Description

@talex5

Another GC problem. If you change the example like this:

$ git diff
------ examples/triangle.ml
++++++ examples/triangle.ml
@|-303,11 +303,15 ============================================================
 |    let vert_shader = create_shader "vertex" vert
 |
 |    let make_stage stage module' =
+|      let x =
 |        Vkt.Pipeline_shader_stage_create_info.make
 |          ~stage
 |          ~module'
 |          ~name: "main"
 |          ()
+|      in
+|      Gc.full_major ();
+|      x
 |
 |    let frag_stage = make_stage Vkt.Shader_stage_flags.fragment frag_shader
 |    let vert_stage = make_stage Vkt.Shader_stage_flags.vertex vert_shader

then it fails:

$ make test-triangle
...
Success: Creating render pass
Fatal error: exception File "lib/Vk__Subresult.ml", line 100, characters 13-19: Assertion failed

Also, I'm a bit unsure about this

olivine/aster/structured.ml

Lines 450 to 453 in 61ad088

let keep_field_alive vars acc = function
(* | Ty.Simple(_,Array _ ) -> acc *)
| Ty.Simple(f, _ ) -> ex (M.find @@ varname f) vars :: acc
| _ -> acc

It seems that Olivine structs hold on to simple fields, but not to arrays. Is that safe?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions