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

obj: allocation is partially outside the pool #4528

Closed
igchor opened this issue Jan 31, 2020 · 1 comment
Closed

obj: allocation is partially outside the pool #4528

igchor opened this issue Jan 31, 2020 · 1 comment
Labels
libpmemobj src/libpmemobj Type: Bug A previously unknown bug in PMDK

Comments

@igchor
Copy link
Contributor

igchor commented Jan 31, 2020

ISSUE: obj: allocation is partially outside the pool

Environment Information

  • PMDK package version(s): 1.7, 1.6, 1.5, 1.4
  • OS(es) version(s):
  • ndctl version(s):
  • kernel version(s):
  • compiler, libraries, packaging and other related tools version(s):

Please provide a reproduction of the bug:

Reproduction is available here: https://github.com/igchor/obj_repro

Accessing memory returned by pmemobj_tx_xalloc causes segfault.

How often bug is revealed: (always, often, rare):

rare - only if pool has certain size and with specific allocation sizes

Actual behavior:

Segfault when accessing memory

Expected behavior:

No segfault, memory is within the pool

Details

Allocator did not take the size of all possible metadata when calculating total available heap size for user allocations.

Additional information about Priority and Help Requested:

Are you willing to submit a pull request with a proposed change? (Yes, No)

Requested priority: (Showstopper, High, Medium, Low)

@igchor igchor added the Type: Bug A previously unknown bug in PMDK label Jan 31, 2020
@marcinslusarz
Copy link
Contributor

Quoting Piotr (#4522):

The calculations for total available heap size for user
allocations didn't take all possible metadata into account,
leading to situations where for certain heap sizes
the zone size was too large by a chunk.

To hit this problem the pool has to be almost full. The heap size calculation can be off by 1kB. There's 1/256 chance of hitting this problem for randomly sized pool. However, for pools whose size is a multiple of 1MB (1048576 bytes), the problem doesn't occur.

PMDK 1.8 fixes this problem for newly created pools. The fix for pools created with older versions will be part of PMDK 1.8.1, along with patches for previous stable branches.

For now, the workaround for this problem in the case of pools on FSDAX is to manually extend the pool by 1kB. Pools on Device DAX with default alignment (2MB) are not affected because theirs sizes must be a multiple of 1MB. For pools on Device DAX with 4kB alignment, there's no known workaround if the problem has been hit.

@marcinslusarz marcinslusarz changed the title Memory allocated by pmemobj_tx_xalloc is partially outside the pool obj: allocation is partially outside the pool Jan 31, 2020
@marcinslusarz marcinslusarz added the libpmemobj src/libpmemobj label Mar 31, 2020
@pbalcer pbalcer closed this as completed Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libpmemobj src/libpmemobj Type: Bug A previously unknown bug in PMDK
Projects
None yet
Development

No branches or pull requests

3 participants