Checked Then Freed
Two threads in a connection server:
/* worker thread */
if (conn->hostname) {
log_line("serving %s", conn->hostname);
}
/* reaper thread */
free(conn->hostname);
conn->hostname = NULL;
Under load the worker segfaults inside log_line on a pointer that tested non-NULL microseconds earlier. Which change fixes it?
Sign in to answer questions and track your progress
Sign In