Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible deadlock issues #832

Open
ryancaicse opened this issue Mar 25, 2022 · 1 comment
Open

Possible deadlock issues #832

ryancaicse opened this issue Mar 25, 2022 · 1 comment

Comments

@ryancaicse
Copy link

It seems mutexp is not released before returning 422 and 427. Should it be a bug?

bfgminer/driver-modminer.c

Lines 404 to 427 in 8e0278a

mutex_lock(mutexp);
fd = modminer->device->device_fd;
if (fd == -1) {
// Died in another thread...
mutex_unlock(mutexp);
return false;
}
cmd[0] = MODMINER_GET_USERCODE;
cmd[1] = fpgaid;
if (write(fd, cmd, 2) != 2)
bailout2(LOG_ERR, "%s: Error writing (read USER code)", modminer->proc_repr);
if (serial_read(fd, buf, 4) != 4)
bailout2(LOG_ERR, "%s: Error reading (read USER code)", modminer->proc_repr);
if (memcmp(buf, BISTREAM_USER_ID, 4)) {
applog(LOG_ERR, "%s: FPGA not programmed", modminer->proc_repr);
if (!modminer_fpga_upload_bitstream(modminer))
return false;
} else if (opt_force_dev_init && !((struct modminer_fpga_state *)modminer->device->thr[0]->cgpu_data)->pdone) {
applog(LOG_DEBUG, "%s: FPGA is already programmed, but --force-dev-init is set",
modminer->proc_repr);
if (!modminer_fpga_upload_bitstream(modminer))
return false;

@ryancaicse
Copy link
Author

Similar to the below. It may occur with very low probability

bfgminer/driver-proxy.c

Lines 95 to 115 in 8e0278a

mutex_lock(&proxy_clients_mutex);
HASH_FIND_STR(proxy_clients, username, client);
if (!client)
{
user = strdup(username);
cgpu = malloc(sizeof(*cgpu));
client = malloc(sizeof(*client));
*cgpu = (struct cgpu_info){
.drv = &proxy_drv,
.set_device_funcs = proxy_set_device_funcs,
.threads = 0,
.device_data = client,
.device_path = user,
};
timer_set_now(&cgpu->cgminer_stats.start_tv);
if (unlikely(!create_new_cgpus(add_cgpu_live, cgpu)))
{
free(client);
free(cgpu);
free(user);
return NULL;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant