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

Incorrect bigarray custom block size #5761

vicuna opened this issue Sep 18, 2012 · 3 comments

Incorrect bigarray custom block size #5761

vicuna opened this issue Sep 18, 2012 · 3 comments


Copy link

@vicuna vicuna commented Sep 18, 2012

Original bug ID: 5761
Reporter: vouillon
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2015-12-11T18:19:43Z)
Resolution: fixed
Priority: high
Severity: major
OS: Mac OS X
Version: 4.00.0
Target version: 4.00.1+dev
Fixed in version: 4.00.1+dev
Category: otherlibs
Related to: #5516
Monitored by: @hcarty

Bug description

The fix to issue #5516 introduced a bug.

The size of bigarray custom blocks is computed as follows:

sizeof(struct caml_ba_array) + (num_dims - 1) * sizeof(intnat)

(in functions caml_ba_alloc and caml_ba_deserialize).

This is too small by one when a C99's flexible array type is used:

#if (STDC_VERSION >= 199901L)
intnat dim[] /[num_dims]/; /* Size in each dimension /
intnat dim[1] /
[num_dims]/; / Size in each dimension */

File attachments

Copy link

@vicuna vicuna commented Sep 19, 2012

Comment author: vouillon

In fact, only serialization is affected. I have uploaded a fix.

But maybe we should use offsetof rather than conditional directives?

offsetof(struct caml_ba_array, dim) + num_dims * sizeof(intnat)

Copy link

@vicuna vicuna commented Sep 27, 2012

Comment author: @damiendoligez

patch applied in 4.00.1+dev (r 12963) and trunk (r 12964)

Left as "resolved" (instead of closed) because Xavier wants to do some refactoring on this code.

Copy link

@vicuna vicuna commented Oct 7, 2012

Comment author: @xavierleroy

Refactoring of this code in the trunk, commit 12993.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants