Closed woonhak closed 7 years ago
I found what is the problem.
if rwlock_init called before previous lock variable not unlocked, then clht can't find previous lock object.
Following example1.cc always dead because of this problem.
#include <iostream>
#include <pthread.h>
int main(int argc, char **argv)
{
static pthread_rwlock_t rwlock, rwlock1;
pthread_rwlock_init(&rwlock, NULL);
pthread_rwlock_wrlock(&rwlock);
pthread_rwlock_init(&rwlock1, NULL);
pthread_rwlock_wrlock(&rwlock1);
//segment fault at following line
pthread_rwlock_unlock(&rwlock);
pthread_rwlock_unlock(&rwlock1);
pthread_rwlock_destroy(&rwlock);
pthread_rwlock_destroy(&rwlock1);
std::cout<<"done"<<std::endl;
return 0;
}
Hi @woonhak,
Thanks for discovering this bug. I pushed a fix that should avoid the crashes (at least on your two examples). Can you please test with the latest master version and tell me if it's OK?
You fixed this issue exactly what I thought It works fine now. Thanks for the fix.
If an application uses google flags, the call pthread_mutex_init invokes segment fault.
Env Ubuntu 14.04 libgflags-dev 2.0-1.1ubuntu1 gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3)
Topology
define NUMA_NODES 4
define CPU_NUMBER 64
define L_CACHE_LINE_SIZE 128
define PAGE_SIZE 4096
Following is a simple example:
example.cc
build g++ -o example example.cc -lgflags -lpthread
run /path/to/litl/lib{lock}_{waiting_policy} ./example -> segment fault
reason call (REAL)(pthread_mutex_init) failed, because real_pthread_mutexinit{lock} is NULL and not correctly linked.