-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Description
Hi, developers, thank you for your checking. The lock &gdb->client_mutex may be acquired twice, which can lead to deadlock? Also, it seems the lock &gdb->client_mutex is not released in the thread correctly because there is no cen64_mutex_unlock(&gdb->client_mutex); statement.
Line 85 in 1b31ca9
| cen64_mutex_lock(&gdb->client_mutex); |
Line 91 in 1b31ca9
| cen64_mutex_lock(&gdb->client_mutex); |
The relevant code is shown:
CEN64_THREAD_RETURN_TYPE gdb_thread(void *opaque) {
cen64_thread_setname(NULL, "gdb");
struct gdb *gdb = (struct gdb *) opaque;
cen64_mutex_lock(&gdb->client_mutex); // acquire the lock first time
// wait until first breakpoint is hit before entering loop
if (gdb->flags & GDB_FLAGS_INITIAL) {
cen64_cv_wait(&gdb->client_semaphore, &gdb->client_mutex);
} else {
cen64_mutex_lock(&gdb->client_mutex); // acquire the lock second time
}
...;
return CEN64_THREAD_RETURN_VAL;
}
cen64_cold bool gdb_init(struct gdb* gdb, struct cen64_device* device, const char* host) {
...;
if (cen64_thread_create(&gdb->thread, gdb_thread, gdb)) { // thread call site
cen64_mutex_destroy(&gdb->client_mutex);
cen64_cv_destroy(&gdb->client_semaphore);
printf("Failed to create gdb thread.\n");
return false;
}
return true;
}
Metadata
Metadata
Assignees
Labels
No labels