Use the [un]defer_signals() functions to prevent signal delivery while
being in the allocator. Fixed bug #1965. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25452 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
SubDir HAIKU_TOP src system libroot posix malloc ;
|
SubDir HAIKU_TOP src system libroot posix malloc ;
|
||||||
|
|
||||||
UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ;
|
UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ;
|
||||||
|
UsePrivateHeaders libroot ;
|
||||||
|
|
||||||
MergeObject posix_malloc.o :
|
MergeObject posix_malloc.o :
|
||||||
arch-specific.cpp
|
arch-specific.cpp
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <user_thread.h>
|
||||||
|
|
||||||
#include "tracing_config.h"
|
#include "tracing_config.h"
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
@@ -265,8 +267,11 @@ malloc(size_t size)
|
|||||||
size += 2 * HEAP_WALL_SIZE;
|
size += 2 * HEAP_WALL_SIZE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
defer_signals();
|
||||||
|
|
||||||
void *addr = pHeap->getHeap(pHeap->getHeapIndex()).malloc(size);
|
void *addr = pHeap->getHeap(pHeap->getHeapIndex()).malloc(size);
|
||||||
if (addr == NULL) {
|
if (addr == NULL) {
|
||||||
|
undefer_signals();
|
||||||
errno = B_NO_MEMORY;
|
errno = B_NO_MEMORY;
|
||||||
KTRACE("malloc(%lu) -> NULL", size);
|
KTRACE("malloc(%lu) -> NULL", size);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -275,6 +280,9 @@ malloc(size_t size)
|
|||||||
#if HEAP_LEAK_CHECK
|
#if HEAP_LEAK_CHECK
|
||||||
add_address(addr, size);
|
add_address(addr, size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
undefer_signals();
|
||||||
|
|
||||||
#if HEAP_WALL
|
#if HEAP_WALL
|
||||||
addr = set_wall(addr, size);
|
addr = set_wall(addr, size);
|
||||||
#endif
|
#endif
|
||||||
@@ -295,8 +303,11 @@ calloc(size_t nelem, size_t elsize)
|
|||||||
size += 2 * HEAP_WALL_SIZE;
|
size += 2 * HEAP_WALL_SIZE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
defer_signals();
|
||||||
|
|
||||||
void *ptr = pHeap->getHeap(pHeap->getHeapIndex()).malloc(size);
|
void *ptr = pHeap->getHeap(pHeap->getHeapIndex()).malloc(size);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
|
undefer_signals();
|
||||||
errno = B_NO_MEMORY;
|
errno = B_NO_MEMORY;
|
||||||
KTRACE("calloc(%lu, %lu) -> NULL", nelem, elsize);
|
KTRACE("calloc(%lu, %lu) -> NULL", nelem, elsize);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -305,6 +316,9 @@ calloc(size_t nelem, size_t elsize)
|
|||||||
#if HEAP_LEAK_CHECK
|
#if HEAP_LEAK_CHECK
|
||||||
add_address(ptr, size);
|
add_address(ptr, size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
undefer_signals();
|
||||||
|
|
||||||
#if HEAP_WALL
|
#if HEAP_WALL
|
||||||
ptr = set_wall(ptr, size);
|
ptr = set_wall(ptr, size);
|
||||||
size -= 2 * HEAP_WALL_SIZE;
|
size -= 2 * HEAP_WALL_SIZE;
|
||||||
@@ -321,17 +335,23 @@ extern "C" void
|
|||||||
free(void *ptr)
|
free(void *ptr)
|
||||||
{
|
{
|
||||||
static processHeap *pHeap = getAllocator();
|
static processHeap *pHeap = getAllocator();
|
||||||
|
|
||||||
#if HEAP_WALL
|
#if HEAP_WALL
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return;
|
return;
|
||||||
KTRACE("free(%p)", ptr);
|
KTRACE("free(%p)", ptr);
|
||||||
ptr = check_wall((uint8*)ptr);
|
ptr = check_wall((uint8*)ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
defer_signals();
|
||||||
|
|
||||||
#if HEAP_LEAK_CHECK
|
#if HEAP_LEAK_CHECK
|
||||||
if (ptr != NULL)
|
if (ptr != NULL)
|
||||||
remove_address(ptr);
|
remove_address(ptr);
|
||||||
#endif
|
#endif
|
||||||
pHeap->free(ptr);
|
pHeap->free(ptr);
|
||||||
|
|
||||||
|
undefer_signals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -344,9 +364,13 @@ memalign(size_t alignment, size_t size)
|
|||||||
debug_printf("memalign() is not yet supported by the wall code.\n");
|
debug_printf("memalign() is not yet supported by the wall code.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
defer_signals();
|
||||||
|
|
||||||
void *addr = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment,
|
void *addr = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment,
|
||||||
size);
|
size);
|
||||||
if (addr == NULL) {
|
if (addr == NULL) {
|
||||||
|
undefer_signals();
|
||||||
errno = B_NO_MEMORY;
|
errno = B_NO_MEMORY;
|
||||||
KTRACE("memalign(%lu, %lu) -> NULL", alignment, size);
|
KTRACE("memalign(%lu, %lu) -> NULL", alignment, size);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -356,6 +380,8 @@ memalign(size_t alignment, size_t size)
|
|||||||
add_address(addr, size);
|
add_address(addr, size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
undefer_signals();
|
||||||
|
|
||||||
KTRACE("memalign(%lu, %lu) -> %p", alignment, size, addr);
|
KTRACE("memalign(%lu, %lu) -> %p", alignment, size, addr);
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
@@ -372,9 +398,11 @@ posix_memalign(void **_pointer, size_t alignment, size_t size)
|
|||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
static processHeap *pHeap = getAllocator();
|
static processHeap *pHeap = getAllocator();
|
||||||
|
defer_signals();
|
||||||
void *pointer = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment,
|
void *pointer = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment,
|
||||||
size);
|
size);
|
||||||
if (pointer == NULL) {
|
if (pointer == NULL) {
|
||||||
|
undefer_signals();
|
||||||
KTRACE("posix_memalign(%p, %lu, %lu) -> NULL", _pointer, alignment,
|
KTRACE("posix_memalign(%p, %lu, %lu) -> NULL", _pointer, alignment,
|
||||||
size);
|
size);
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@@ -384,6 +412,8 @@ posix_memalign(void **_pointer, size_t alignment, size_t size)
|
|||||||
add_address(pointer, size);
|
add_address(pointer, size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
undefer_signals();
|
||||||
|
|
||||||
*_pointer = pointer;
|
*_pointer = pointer;
|
||||||
KTRACE("posix_memalign(%p, %lu, %lu) -> %p", _pointer, alignment, size,
|
KTRACE("posix_memalign(%p, %lu, %lu) -> %p", _pointer, alignment, size,
|
||||||
pointer);
|
pointer);
|
||||||
|
|||||||
Reference in New Issue
Block a user