llnl / llnl/zfp

Relative error bound results in out-of-bounds access after zfp_stream_maximum_size

Open
#272 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug documentation
Dominant language
C++
Stars
885
Forks
181
PR merge metrics
No merged PRs in 30d

Description

@treigerm and I are trying to use the relative error bound as suggested in the FAQ:

```
minbits = 0
maxbits = 0
maxprec = p
minexp = ZFP_MIN_EXP - 1 = -1075
```

However, in https://github.com/LLNL/zfp/blob/4baa4c7eeae8e0b6a7ace4dde242ac165bcd59d9/src/zfp.c#L743-L785

this configuration results in an invalid capacity, which produces an out-of-bounds access soon after:

```
maxsize = 0;
maxbits = 9; // float
maxbits += values - 1 + values * p;
maxbits = MIN(maxbits, zfp->maxbits=0);
// maxbits is now 0
maxbits = MAX(maxbits, zfp->minbits);

maxsize = ZFP_HEADER_MAX_BITS + blocks * maxbits;
// maxsize is just ZFP_HEADER_MAX_BITS
```

@lindstro How should we compute the capacity when using the relative error expert mode?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the relative-error expert-mode settings in the FAQ and src/zfp.c around lines 743-785, then trace zfp_stream_maximum_size with the reported minbits, maxbits, maxprec, and minexp values. Reproduce the invalid capacity and out-of-bounds access, and establish what capacity behavior should be expected for this configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.