Hey guys,
Yes, the internal mapping algorithm used by pmem_map_file is not
thread-safe. However for this API the only thing affected by this bug
is performance - if there's a race between two threads (one calling
pmem_map_file and another calling regular mmap) the mmap from
pmem_map_file may ignore the hint address and create unaligned
mapping, which means huge pages won't be used.
Chris, I suspect the error you are seeing comes from your application
either not unmapping at all or calling pmem_unmap with wrong length.
If you are sure it's not true, then I think we'll need a reproducer.
Fixing the mapping algorithm bug for Linux should be relatively easy
(just do not unmap temporary VM space and then map with MAP_FIXED),
but our Windows implementation of mmap doesn't seem to handle
MAP_FIXED correctly, so it will require more work.
At the beginning I said that this bug doesn't affect correctness of
pmem_map_file, but it affects pmemobj correctness in one case -
allocations with alignment (introduced in 1.5) between 8kB and 2MB
(the max value) may not actually be aligned if pool opening raced with
another thread mapping something and OS decided to use non-2MB aligned
address. If application relies on this (for example by assuming lower
bits of PMEMoid are 0), it may lead to corruption. We'll have to fix
this somehow. I'll open bug report tomorrow if nobody will find any
hole in this theory.
Marcin
> --
> You received this message because you are subscribed to the Google Groups "pmem" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
pmem+uns...@googlegroups.com.
> To post to this group, send email to
pm...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/pmem/c4759576-1191-499d-a7a8-047f83292969%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.