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

bigarray: fix deserialization of float16 bigarrays #12499

Merged
merged 1 commit into from
Aug 26, 2023

Conversation

gasche
Copy link
Member

@gasche gasche commented Aug 24, 2023

# let arr = Bigarray.(Array1.create float16 c_layout 10);;
val arr : (float, Bigarray.float16_elt, Bigarray.c_layout) Bigarray.Array1.t =
  <abstr>
# let raw = Marshal.to_string arr [];;
val raw : string = [...]
# Marshal.from_string raw 0;;
Exception: Failure "input_value: bad bigarray kind".

(I spotted the bug while reading the code of caml_ba_deserialize.)

@dra27
Copy link
Member

dra27 commented Aug 24, 2023

I think there's a similar issue in the assertion in otherlibs/unix/mmap_ba.c?

runtime/caml/bigarray.h Outdated Show resolved Hide resolved
@gasche gasche changed the title bigarray: fix deserialization of float16 dynarrays bigarray: fix deserialization of float16 bigarrays Aug 24, 2023
@gasche gasche force-pushed the bigarray-float16-fix-deserialization branch from d44844e to 49e80dc Compare August 24, 2023 22:28
@gasche
Copy link
Member Author

gasche commented Aug 24, 2023

I think there's a similar issue in the assertion in otherlibs/unix/mmap_ba.c?

Indeed, I also fixed that one and updated the PR. Thanks!

Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Bug-fix is clearly correct. Although I expect we're not likely to add another type for another 10 years, the use of an UNIMPLEMENTED sentinel should ensure that that next addition is correct! 🙂

    # let arr = Bigarray.(Array1.create float16 c_layout 10);;
    val arr : (float, Bigarray.float16_elt, Bigarray.c_layout) Bigarray.Array1.t =
      <abstr>
    # let raw = Marshal.to_string arr [];;
    val raw : string = [...]
    # Marshal.from_string raw 0;;
    Exception: Failure "input_value: bad bigarray kind".

Co-authored-by: David Allsopp <david.allsopp@metastack.com>
@gasche gasche force-pushed the bigarray-float16-fix-deserialization branch from 49e80dc to f0223c9 Compare August 25, 2023 18:29
@gasche gasche merged commit 24e0fe6 into ocaml:trunk Aug 26, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants