Changeset 25452

Show
Ignore:
Timestamp:
05/11/08 11:30:22 (6 days ago)
Author:
bonefish
Message:
Use the [un]defer_signals() functions to prevent signal delivery while
being in the allocator. Fixed bug #1965.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • haiku/trunk/src/system/libroot/posix/malloc/Jamfile

    r15191 r25452  
    22 
    33UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ; 
     4UsePrivateHeaders libroot ; 
    45 
    56MergeObject posix_malloc.o : 
  • haiku/trunk/src/system/libroot/posix/malloc/wrapper.cpp

    r25213 r25452  
    3030#include <string.h> 
    3131 
     32#include <user_thread.h> 
     33 
    3234#include "tracing_config.h" 
    3335 
     
    266268#endif 
    267269 
     270        defer_signals(); 
     271 
    268272        void *addr = pHeap->getHeap(pHeap->getHeapIndex()).malloc(size); 
    269273        if (addr == NULL) { 
     274                undefer_signals(); 
    270275                errno = B_NO_MEMORY; 
    271276                KTRACE("malloc(%lu) -> NULL", size); 
     
    276281        add_address(addr, size); 
    277282#endif 
     283 
     284        undefer_signals(); 
     285 
    278286#if HEAP_WALL 
    279287        addr = set_wall(addr, size); 
     
    296304#endif 
    297305 
     306        defer_signals(); 
     307 
    298308        void *ptr = pHeap->getHeap(pHeap->getHeapIndex()).malloc(size); 
    299309        if (ptr == NULL) { 
     310                undefer_signals(); 
    300311                errno = B_NO_MEMORY; 
    301312                KTRACE("calloc(%lu, %lu) -> NULL", nelem, elsize); 
     
    306317        add_address(ptr, size); 
    307318#endif 
     319 
     320        undefer_signals(); 
     321 
    308322#if HEAP_WALL 
    309323        ptr = set_wall(ptr, size); 
     
    322336{ 
    323337        static processHeap *pHeap = getAllocator(); 
     338 
    324339#if HEAP_WALL 
    325340        if (ptr == NULL) 
     
    328343        ptr = check_wall((uint8*)ptr); 
    329344#endif 
     345 
     346        defer_signals(); 
     347 
    330348#if HEAP_LEAK_CHECK 
    331349        if (ptr != NULL) 
     
    333351#endif 
    334352        pHeap->free(ptr); 
     353 
     354        undefer_signals(); 
    335355} 
    336356 
     
    345365        return NULL; 
    346366#endif 
     367 
     368        defer_signals(); 
     369 
    347370        void *addr = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment, 
    348371                size); 
    349372        if (addr == NULL) { 
     373                undefer_signals(); 
    350374                errno = B_NO_MEMORY; 
    351375                KTRACE("memalign(%lu, %lu) -> NULL", alignment, size); 
     
    357381#endif 
    358382 
     383        undefer_signals(); 
     384 
    359385        KTRACE("memalign(%lu, %lu) -> %p", alignment, size, addr); 
    360386        return addr; 
     
    373399#endif 
    374400        static processHeap *pHeap = getAllocator(); 
     401        defer_signals(); 
    375402        void *pointer = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment, 
    376403                size); 
    377404        if (pointer == NULL) { 
     405                undefer_signals(); 
    378406                KTRACE("posix_memalign(%p, %lu, %lu) -> NULL", _pointer, alignment, 
    379407                        size); 
     
    384412        add_address(pointer, size); 
    385413#endif 
     414 
     415        undefer_signals(); 
    386416 
    387417        *_pointer = pointer;