curl_slist_free_all() causes segfault on GKE w/ Debian 8.7 curl_slist_free_all() causes segfault on GKE w/ Debian 8.7 kubernetes kubernetes

curl_slist_free_all() causes segfault on GKE w/ Debian 8.7


I suspect this was some sort of subtle incompatibility between the Docker build image and the Docker deploy image that only manifested when running on GKE.


In my case it was like this

if ( strcmp(req->headers, ""){    curl_slist_free_all(list);// segfault}if ( strcmp(req->headers, ""){   // no segfault}

and req->headers was NULL, so whenever I remove the curl_slist_free_all line, the compiler does not produce binary code for this IF statement at all as an optimization step, so the strcmp is not called which was what actually causing the segfault not curl_slist_free_all(list);