From 56b421910f8d037a78c823b07ce2e3b5236d1792 Mon Sep 17 00:00:00 2001 From: Vincent Laviron Date: Tue, 4 Aug 2026 16:48:57 +0200 Subject: [PATCH 1/3] Fix hash computation --- stdlib/introspect.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/introspect.ml b/stdlib/introspect.ml index 4b37072581ea..6b39edf10851 100644 --- a/stdlib/introspect.ml +++ b/stdlib/introspect.ml @@ -125,7 +125,7 @@ module Desc = struct | Record { name; tag; fields } -> hash_array (hash_combine (hash_combine 6 tag) name) fields | Polymorphic_variant -> 7 - | Polymorphic_variant_constant _ -> 0 + | Polymorphic_variant_constant _ -> 8 external read_self_descriptors : unit -> t list = "caml_read_bdsc_section" From c7c37b693864b97f4cfb144e55fd263477ebef0b Mon Sep 17 00:00:00 2001 From: Vincent Laviron Date: Tue, 4 Aug 2026 16:49:35 +0200 Subject: [PATCH 2/3] Only register descriptions if introspection is enabled --- stdlib/introspect.ml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib/introspect.ml b/stdlib/introspect.ml index 6b39edf10851..dfcbae9259e2 100644 --- a/stdlib/introspect.ml +++ b/stdlib/introspect.ml @@ -166,6 +166,9 @@ module Index = struct | tags -> Hashtbl.replace t.descriptors i (tag :: tags) end + let register t desc = + if enabled then register t desc + let make () = let result = raw_make () in register result Desc.unknown; From 6211065223ee787cbdc1c7e7575aa5c63cf2d3b3 Mon Sep 17 00:00:00 2001 From: Vincent Laviron Date: Tue, 4 Aug 2026 16:50:28 +0200 Subject: [PATCH 3/3] Prevent interpretation of non-array values as arrays --- stdlib/introspect.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/introspect.ml b/stdlib/introspect.ml index dfcbae9259e2..55628c909327 100644 --- a/stdlib/introspect.ml +++ b/stdlib/introspect.ml @@ -305,7 +305,9 @@ module Dyn = struct else let osize = Obj.size obj in let select = function - | Desc.Array _ -> true + | Desc.Array _ -> + otag <= Obj.last_non_constant_constructor_tag + || otag = Obj.double_array_tag | Desc.Polymorphic_variant -> osize = 2 | Desc.Tuple t -> otag = t.tag && osize = Array.length t.fields