{"action":"created","issue":{"url":"https://api.github.com/repos/vszakats/harbour-core/issues/240","repository_url":"https://api.github.com/repos/vszakats/harbour-core","labels_url":"https://api.github.com/repos/vszakats/harbour-core/issues/240/labels{/name}","comments_url":"https://api.github.com/repos/vszakats/harbour-core/issues/240/comments","events_url":"https://api.github.com/repos/vszakats/harbour-core/issues/240/events","html_url":"https://github.com/vszakats/harbour-core/issues/240","id":184557834,"number":240,"title":"SIGSEGV when initializing hbcurl","user":{"login":"emazv72","id":5381288,"avatar_url":"https://avatars.githubusercontent.com/u/5381288?v=3","gravatar_id":"","url":"https://api.github.com/users/emazv72","html_url":"https://github.com/emazv72","followers_url":"https://api.github.com/users/emazv72/followers","following_url":"https://api.github.com/users/emazv72/following{/other_user}","gists_url":"https://api.github.com/users/emazv72/gists{/gist_id}","starred_url":"https://api.github.com/users/emazv72/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emazv72/subscriptions","organizations_url":"https://api.github.com/users/emazv72/orgs","repos_url":"https://api.github.com/users/emazv72/repos","events_url":"https://api.github.com/users/emazv72/events{/privacy}","received_events_url":"https://api.github.com/users/emazv72/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-21T20:06:12Z","updated_at":"2016-10-21T23:30:17Z","closed_at":null,"body":"\r\n- [x] Have you read the [CONTRIBUTING](CONTRIBUTING.md) document?\r\n- [x] Does the issue happen with the _latest_ 3.4 revision?\r\n\r\n### Bug reports:\r\n\r\nCalling hbcurl with latest libcurl causes a SIGSEGV.\r\n\r\nSample code:\r\n~~~~\r\n    CURL_GLOBAL_INIT()\r\n\r\n    pCurl := CURL_EASY_INIT()\r\n\r\n    IF ( !EMPTY(pCurl))\r\n        CURL_EASY_CLEANUP(pCurl)\r\n    ENDIF\r\n~~~~\r\n\r\nAfter a in-depth debugging session, I found the root cause to be the callbacks in _hbcurl_ _global.c_ _curl_global_init_mem()_\r\n\r\nNew releases of libcurl seem not to be compatible with Harbour memory allocation functions.\r\n\r\nRepro is provided here [test_hb_curl.zip](https://github.com/vszakats/harbour-core/files/544895/test_hb_curl.zip)\r\n\r\nCompiling with\r\n\r\n    hbmk2 -cflag=-DUSE_HB_MF testcurl1.prg testcurl.c\r\n\r\nshows the issue.\r\n\r\nCompiling with\r\n\r\n    hbmk2 -cflag=testcurl1.prg testcurl.c\r\n\r\nuses the C runtime instead and doesn't hang.\r\n\r\n## Environment:\r\n\r\n* Windows 2012R2/Windows 10\r\n* msys2-x86_64-20160921\r\n* gcc (Rev2, Built by MSYS2 project) 6.2.0  - 32 bit\r\n* libcurl/7.50.3 OpenSSL/1.0.2j zlib/1.2.8 libidn/1.33 libssh2/1.7.0 nghttp2/1.15.0 librtmp/2.3\r\n\r\n## Workaround\r\n\r\nAn additional parameter can be added like this:\r\n\r\n    CURL_GLOBAL_INIT(nFlags, bUseHarbourMemFuncs)\r\n\r\nAnother solution would be to add a \r\n\r\n    CURL_GLOBAL_SETUP( bMemStrategy )\r\n\r\nIn order to choose the memory management strategy\r\n\r\nI can issue a PR to fix it and close the issue.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/vszakats/harbour-core/issues/comments/255488822","html_url":"https://github.com/vszakats/harbour-core/issues/240#issuecomment-255488822","issue_url":"https://api.github.com/repos/vszakats/harbour-core/issues/240","id":255488822,"user":{"login":"vszakats","id":1446897,"avatar_url":"https://avatars.githubusercontent.com/u/1446897?v=3","gravatar_id":"","url":"https://api.github.com/users/vszakats","html_url":"https://github.com/vszakats","followers_url":"https://api.github.com/users/vszakats/followers","following_url":"https://api.github.com/users/vszakats/following{/other_user}","gists_url":"https://api.github.com/users/vszakats/gists{/gist_id}","starred_url":"https://api.github.com/users/vszakats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vszakats/subscriptions","organizations_url":"https://api.github.com/users/vszakats/orgs","repos_url":"https://api.github.com/users/vszakats/repos","events_url":"https://api.github.com/users/vszakats/events{/privacy}","received_events_url":"https://api.github.com/users/vszakats/received_events","type":"User","site_admin":false},"created_at":"2016-10-21T23:30:17Z","updated_at":"2016-10-21T23:30:17Z","body":"Hi @emazv72,\r\n\r\nSorry, but I can't reproduce this.\r\n\r\nTried msys2/mingw 32-bit and 64-bit `libcurl/7.50.3 OpenSSL/1.1.0b zlib/1.2.8 WinIDN libssh2/1.7.0 nghttp2/1.15.0` (curl + openssl builds bundled with Harbour 3.4 distro) and darwin/clang `libcurl/7.50.3 OpenSSL/1.0.2j zlib/1.2.5 libssh2/1.7.0 nghttp2/1.15.0` (latest Homebrew curl build).\r\n\r\nAFAIU the workaround you suggest would completely disable the use of Harbour core memory functions. It would be interesting to see what exactly causes such issue before resorting to such drastic workaround. You workaround suggests that either one/some of the Harbour memory function callbacks are incorrect and/or libcurl is not resorting to them in all situations."}}
{"actor":{"display_login":"vszakats"}}