-
-
Notifications
You must be signed in to change notification settings - Fork 249
Closed
Description
Dear developers:
Thank you for your checking. The lock &mutex_mmap may not be released correctly when the condition posix_memalign(&p, box86_pagesize, size) and p==(void*)-1 return 1. The fix is to insert pthread_mutex_lock(&mutex_mmap); // the lock before returning.
Line 427 in 722909a
| pthread_mutex_lock(&mutex_mmap); |
uintptr_t AllocDynarecMap(dynablock_t* db, int size)
{
if(!size)
return 0;
if(size>MMAPSIZE-2*sizeof(blockmark_t)) {
#ifndef USE_MMAP
pthread_mutex_lock(&mutex_mmap); // the lock
void *p = NULL;
if(posix_memalign(&p, box86_pagesize, size)) {
dynarec_log(LOG_INFO, "Cannot create dynamic map of %d bytes\n", size);
return 0; /error 1, return with unreleased lock
}
mprotect(p, size, PROT_READ | PROT_WRITE | PROT_EXEC);
#else
void* p = mmap(NULL, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
if(p==(void*)-1) {
dynarec_log(LOG_INFO, "Cannot create dynamic map of %d bytes\n", size);
return 0; //error 2, return with unreleased lock
}
...;
return ret;
}
Best,
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels