-
Notifications
You must be signed in to change notification settings - Fork 96
fix(container): Propagate engine initialization errors to the caller #1020
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
base: main
Are you sure you want to change the base?
fix(container): Propagate engine initialization errors to the caller #1020
Conversation
e56b8e9 to
c7c0968
Compare
Rules files suggestions |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rabbitstack The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1 similar comment
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rabbitstack The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
If the specific container engine worker fails during initialization, the error is silently skipped making it hard to troubleshoot the real problem. i Instead, accumulate and bubble up all the errors to the async handler. Signed-off-by: rabbitstack <[email protected]>
46c632c to
76943d2
Compare
Rules files suggestions |
| errmsg := C.CString("") | ||
| ptr := StartWorker((*[0]byte)(C.echo_cb), cstr, &enabledSocks, &errmsg) | ||
| if ptr == nil { | ||
| fmt.Println("Failed to start worker; nothing configured?") | ||
| fmt.Println(fmt.Sprintf("Failed to start worker; nothing configured? %s", C.GoString(errmsg))) | ||
| os.Exit(1) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This snippet introduces a memory leak, because C.Cstring("") allocates a C string on the heap, and the Go runtime will not garbage-collect it. We should add a call to defer C.free(...). but in order to be sure that this is called just after StartWorker(...) invocation, and regardless the fact that this function could panic, I would add a new wrapping function like the following:
func startWorker(...) unsafe.Pointer {
errmsg := C.CString("")
defer C.free(unsafe.Pointer(errmsg))
return StartWorker((*[0]byte)(C.echo_cb), cstr, &enabledSocks, &errmsg)
}
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area plugins
What this PR does / why we need it:
Which issue(s) this PR fixes:
If the specific container engine worker fails during initialization, the error is silently skipped, making it hard to troubleshoot the real problem. Instead, accumulate and bubble up all the errors to the async handler.
Special notes for your reviewer: