Am Freitag, den 29.04.2016, 13:04 +0200 schrieb Markus Weißmann: > Hello, > > I have a server program that crashes after some time with a very > strange error: > The (=) comparison of two values returns false, even though they are > pretty identical. > They are of type { a : int; b : int } and the comparison always fails > on the second integer. > When printing the compared integers, they are always 0 (as expected) -- > both of them; but are not equal (=). > I started inspecting the values with the "Obj.tag" and found them to be > always of type Obj.int_tag -- until the non-equalness strikes: > One of the compared integers then always has Obj.out_of_heap_tag. This > value surprisingly behaved like an integer unless compared to another: > > let (x : int) = > print_int x; (* "0" *) > assert (x = 0) (* fails! *) > > Can someone explain what this tag means exactly and if this > works-as-intended or if my heap must have gotten hit by some faulty C > bindings? Obj.tag is meaningless for ints. What could have happened is that a C lib did not set the LSB of the word (which is required for ints in order to make them distinguishable from pointers). The C lib MUST use Val_int or Val_long to create the values (and these macros set the LSB). Check whether Obj.is_int returns true. If not, something is wrong. Actually, I wonder what Obj.int_tag=1000 is for. It's not something that can really occur, because tags are 8 bits wide. Maybe it's a replacement when Obj.tag is called for non-blocks? Gerd > Is this some out-of-memory handling of the minor heap? If I set > Gc.minor_heap_size to 4 MByte I don't get the Obj.out_of_heap_tag -- or > at least haven't yet. > > This is ocaml 4.02.3 on amd64. > > Regards > Markus > > -- > Markus Weißmann, M.Sc. > Technische Universität München > Institut für Informatik > Boltzmannstr. 3 > D-85748 Garching > Germany > http://wwwknoll.in.tum.de/ > > -- ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------