<p>I've been able to reproduce the crash that lead to Dragos analysis and this PR, both in debian 8 and in CentOS 7.</p>
<p>But I tracked it down to a different cause, which is <code>libcurl</code> crashing when using the threaded resolver for DNS lookups. This happens even with latest <code>libcurl</code>.</p>
<p>The work around this was building <code>libcurl</code> with <code>c-ares</code> resolver, and that proved to solve the issue. This included tests under heavy load (hundreds of requests per second).</p>
<p>I meant to write my findings to the libcurl mailing list and ask for corroboration or indications, but I haven't had time yet, as bringing up the failing and working scenarios in a clean way to be shared with that ml is very time consuming.</p>
<p>For what concerns this specific Pull Request I haven't done any test/verification. I don't have it in the environments with the c-ares fix and there are no crashes, so perhaps it's not needed.<br>
The only thing I can suggest is that next time I do the load testing, I use the patch in this PR to verify there are no side effects.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/1407#issuecomment-425080622">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZQIDnPoL5ccMJJppqx6UNKYiiHswks5ufMthgaJpZM4Rp7V4">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZdhQRR1tfmId5IU6fV_WFu8cabM_ks5ufMthgaJpZM4Rp7V4.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@giavac in #1407: I've been able to reproduce the crash that lead to Dragos analysis and this PR, both in debian 8 and in CentOS 7.\r\n\r\nBut I tracked it down to a different cause, which is `libcurl` crashing when using the threaded resolver for DNS lookups. This happens even with latest `libcurl`.\r\n\r\nThe work around this was building `libcurl` with `c-ares` resolver, and that proved to solve the issue. This included tests under heavy load (hundreds of requests per second).\r\n\r\nI meant to write my findings to the libcurl mailing list and ask for corroboration or indications, but I haven't had time yet, as bringing up the failing and working scenarios in a clean way to be shared with that ml is very time consuming.\r\n\r\nFor what concerns this specific Pull Request I haven't done any test/verification. I don't have it in the environments with the c-ares fix and there are no crashes, so perhaps it's not needed.\r\nThe only thing I can suggest is that next time I do the load testing, I use the patch in this PR to verify there are no side effects.\r\n"}],"action":{"name":"View Pull Request","url":"https://github.com/kamailio/kamailio/pull/1407#issuecomment-425080622"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/1407#issuecomment-425080622",
"url": "https://github.com/kamailio/kamailio/pull/1407#issuecomment-425080622",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [kamailio/kamailio] http_async_client: memory mismanagement (#1407)",
"sections": [
{
"text": "",
"activityTitle": "**Giacomo Vacca**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@giavac",
"facts": [

]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1407,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close pull request",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"PullRequestClose\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"pullRequestId\": 1407\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/kamailio/kamailio/pull/1407#issuecomment-425080622"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 296203640\n}"
}
],
"themeColor": "26292E"
}
]</script>