udo-munk / z80pack

A Zilog Z80 and Intel 8080 systems emulation
MIT License
158 stars 37 forks source link

No mutex initialisation for data_sample_lock in lp_main.cpp #7

Closed dmcnaugh closed 6 years ago

dmcnaugh commented 6 years ago

In the frontpanel module lp_main.cpp there are 2 mutexes defined:

//static pthread_mutex_t data_lock;
pthread_mutex_t data_lock;
pthread_mutex_t data_sample_lock;

however, only the first one is ever initialised in start_threads()

pthread_mutex_init(&data_lock,NULL);

So every call to lock and unlock this mutex fails, although this does not appear to effect the operation of the frontpanel library. So there are 2 alternatives:

  1. initialise the second mutex in start_threads()

    pthread_mutex_init(&data_lock,NULL);
    pthread_mutex_init(&data_sample_lock,NULL);

    or

  2. remove the references in lp_main.cpp and lpanel.cpp to:

    pthread_mutex_lock(&data_sample_lock);
    ...
    pthread_mutex_unlock(&data_sample_lock);

There is a proposed fix in Pull-Request #6

udo-munk commented 6 years ago

Certainly an old bug missed so far. Fixed, thanks.