Project

General

Profile

Feature #3000

umem should support posix_memalign()

Added by Bob Friesenhahn over 8 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
Low
Category:
lib - userland libraries
Start date:
2012-07-15
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Libumem is described as being a replacement for the standard malloc functions. Illumos supports posix_memalign() in its standard C library. If libumem is used as a substitute to provide the standard allocation functions (at link time or run-time) and the application is using posix_memalign(), there will be a mix of allocator functions used (e.g. free() from umem used on pointer allocated by standard C library posix_memalign()) and the application is likely to fail. The solution for this is for libumem to also support posix_memalign().

Libumem already provides memalign().

#1

Updated by Robert Mustacchi over 8 years ago

  • Assignee set to Robert Mustacchi
#2

Updated by Robert Mustacchi over 8 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100
  • Tags deleted (needs-triage)

While libumem does not have an explicit posix_memalign entry point, posix_memalign in libc is very simple. It does explicit checks required by SUSv3 and just calls memalign to do the necessary work. Because memalign is implemented in libumem, we use the libumem version. Therefore, when we call free, we will be calling the appropriate free entry point.

As validation, construct the following simple C program:

#include <sys/mman.h>

int
main(void)
{
        void *buf;

        return (posix_memalign(&buf, 4*1024, 4*1024));
}

When you run this with LD_PRELOAD=libumem.so and take a look at mdb, you'll note that the posix_memalign function is taking you towards libumem's implementation of memalign.

> ::step
mdb: target stopped at:
libc.so.1`posix_memalign+0x3f:  call   -0x31c54 <PLT=libumem.so.1`memalign>

Also available in: Atom PDF