Skip to content

Possible deadlock issues #224

@ryancaicse

Description

@ryancaicse

Hi, it seems that lock device->sync_mutex is missed to be released after 248. In the while loop, the lock could be acquired twice and a deadlock occurs.

cen64/device/device.c

Lines 230 to 256 in 1b31ca9

while (likely(device->running)) {
unsigned i, j;
for (i = 0; i < 6250 / 2; i++) {
for (j = 0; j < 2; j++) {
ai_cycle(&device->ai);
pi_cycle(&device->pi);
}
for (j = 0; j < 3; j++)
vr4300_cycle(device->vr4300);
}
// Sync up with the RCP thread.
cen64_mutex_lock(&device->sync_mutex);
if (!device->other_thread_is_waiting) {
device->other_thread_is_waiting = true;
cen64_cv_wait(&device->sync_cv, &device->sync_mutex);
}
else {
device->other_thread_is_waiting = false;
cen64_mutex_unlock(&device->sync_mutex);
cen64_cv_signal(&device->sync_cv);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions