Skip to content

Commit e0e34a7

Browse files
authored
Merge pull request #15 from corazawaf/fix/keep-libcoraza-loaded
Keep libcoraza loaded for the process lifetime
2 parents a83c85b + 1981b45 commit e0e34a7

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/mod_coraza_dl.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,23 @@ coraza_dl_open(server_rec *s)
156156
}
157157

158158
/* ------------------------------------------------------------------ */
159-
/* Public: unload libcoraza.so */
159+
/* Public: keep libcoraza.so loaded until the process exits */
160+
/* */
161+
/* libcoraza embeds a Go runtime, and a Go runtime cannot be safely */
162+
/* unloaded with dlclose(): its signal handlers, GC threads and TLS */
163+
/* blocks stay registered, so unloading the .so leaves dangling */
164+
/* pointers and crashes on teardown. This runs from the child-pool */
165+
/* cleanup (coraza_child_exit), which fires on worker shutdown and on */
166+
/* graceful restart, so we must not unload here -- leave the handle in */
167+
/* place and let normal process exit reclaim it. */
160168
/* ------------------------------------------------------------------ */
161169

162170
void
163171
coraza_dl_close(server_rec *s)
164172
{
165173
if (dl_handle != NULL) {
166-
dynlib_close(dl_handle);
167-
dl_handle = NULL;
168-
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s,
169-
"coraza: %s unloaded",
174+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
175+
"coraza: %s left loaded for process lifetime",
170176
CORAZA_DYNLIB_BASENAME DYNLIB_EXT);
171177
}
172178
}

0 commit comments

Comments
 (0)