microsoft / microsoft/mimalloc

The value that can be passed to the `offset` parameter of `mi_malloc_aligned_at()`

Open
#417 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

Code for passing a value that is not a multiple of the pointer size to the `offset` parameter of the `mi_malloc_aligned_at()` function and passing the returned pointer to the `mi_free()` function:
````c
#include "mimalloc.h"

int main(void) {
void *p = mi_malloc_aligned_at(50, 32, 4);
mi_free(p);
return 0;
}
````

in debug mode, you will get the following error message.
```
mimalloc: error: mi_free: invalid (unaligned) pointer: 0x2000000152f
````

Is it a specification that the value of the `offset` parameter must be a multiple of the pointer size?

Contributor guide

No contributing guide indexed for this repository

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 mi_malloc_aligned_at() and mi_free() declarations and documentation in mimalloc.h, using the provided C example as the reproduction case. Determine whether a non-pointer-size-multiple offset is supported and document the expected offset and freeing behavior; the issue is done when the specification is explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.