Describe the bug
The following causes a hung process on AlmaLinux 9 and Ubuntu 22:
#include <stdio.h>
#include <stdlib.h>
#include <sys/select.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "unbound.h"
void my_cb(void* my_arg, int err, struct ub_result* result) {
printf("callback called\n");
}
int main() {
struct ub_ctx* ub = ub_ctx_create();
ub_ctx_async(ub, 1);
ub_resolve_async(ub, "google.com", 1, 1, NULL, my_cb, NULL);
ub_wait(ub);
pid_t pid = fork();
if (!pid) {
printf("child reaping\n");
ub_ctx_delete(ub);
printf("child reaped\n");
exit(0);
}
int status;
wait(&status);
printf("parent reaping\n");
ub_ctx_delete(ub); // hang is here
printf("parent reaped\n");
return 0;
}
To reproduce
Steps to reproduce the behavior:
- On AlmaLinux 9: Compile the above, modifying as appropriate to find
unbound.h and linked to libunbound.
- Run the resulting binary.
Expected behavior
The process should finish. (It does on AlmaLinux 8.)
System:
- Unbound version: 1.17.0
- OS: AlmaLinux 9
unbound -V output: (Not relevant; we only use libunbound, not the daemon.)
Additional information
The 2nd ub_ctx_delete is doing a read that hangs. It sends \4\0\0\0\0\0\0\0 and expects a response; that response comes in the child process (the first one to do the reap), but the parent process doesn’t get a response.
I don’t see anything in the documentation that suggests this shouldn’t work at least insofar as not causing a hang. Maybe some sort of timeout in ub_ctx_delete would be worthwhile?
Contexts where I see this bug:
- AlmaLinux 9
- Ubuntu 22.04 (containerized from AL9)
Contexts where I don’t see this bug:
- AlmaLinux 8 (virtualized)
- AlmaLinux 8 (containerized from AL9)
- Ubuntu 20.04 (virtualized)
Given the above, the issue would seem to be in user space.
Describe the bug
The following causes a hung process on AlmaLinux 9 and Ubuntu 22:
To reproduce
Steps to reproduce the behavior:
unbound.hand linked to libunbound.Expected behavior
The process should finish. (It does on AlmaLinux 8.)
System:
unbound -Voutput: (Not relevant; we only use libunbound, not the daemon.)Additional information
The 2nd
ub_ctx_deleteis doing a read that hangs. It sends\4\0\0\0\0\0\0\0and expects a response; that response comes in the child process (the first one to do the reap), but the parent process doesn’t get a response.I don’t see anything in the documentation that suggests this shouldn’t work at least insofar as not causing a hang. Maybe some sort of timeout in
ub_ctx_deletewould be worthwhile?Contexts where I see this bug:
Contexts where I don’t see this bug:
Given the above, the issue would seem to be in user space.