{"action":"created","issue":{"url":"https://api.github.com/repos/krakjoe/pthreads/issues/471","labels_url":"https://api.github.com/repos/krakjoe/pthreads/issues/471/labels{/name}","comments_url":"https://api.github.com/repos/krakjoe/pthreads/issues/471/comments","events_url":"https://api.github.com/repos/krakjoe/pthreads/issues/471/events","html_url":"https://github.com/krakjoe/pthreads/issues/471","id":100952179,"number":471,"title":"libcurl and segmentation fault","user":{"login":"qiukeren","id":2325492,"avatar_url":"https://avatars.githubusercontent.com/u/2325492?v=3","gravatar_id":"","url":"https://api.github.com/users/qiukeren","html_url":"https://github.com/qiukeren","followers_url":"https://api.github.com/users/qiukeren/followers","following_url":"https://api.github.com/users/qiukeren/following{/other_user}","gists_url":"https://api.github.com/users/qiukeren/gists{/gist_id}","starred_url":"https://api.github.com/users/qiukeren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiukeren/subscriptions","organizations_url":"https://api.github.com/users/qiukeren/orgs","repos_url":"https://api.github.com/users/qiukeren/repos","events_url":"https://api.github.com/users/qiukeren/events{/privacy}","received_events_url":"https://api.github.com/users/qiukeren/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-14T07:28:40Z","updated_at":"2015-08-14T07:32:08Z","closed_at":null,"body":"1.I use the github version of pthreads,\r\n2.libcurl version is libcurl4.1.1(centos libcurl-7.19.7 package)\r\n3.php version 5.6.11\r\n\r\nThe problem is, the segmentation fault comes sometimes,especially  when i run php X.php the first time in a terminal\r\n\r\nand the code is\r\n```\r\n<?php\r\n class test extends Thread {\r\n    public $url;\r\n    public $result;\r\n    \r\n    public function __construct($url) {\r\n        $this->url = $url;\r\n    }\r\n    \r\n    public function run() {\r\n        if ($this->url) {\r\n            $this->result = model_http_curl_get($this->url);\r\n        }\r\n    }\r\n }\r\n function model_http_curl_get($url) {\r\n    $curl = curl_init();  \r\n    curl_setopt($curl, CURLOPT_URL, $url);  \r\n    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  \r\n    curl_setopt($curl, CURLOPT_TIMEOUT, 5);  \r\n    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)');  \r\n    $result = curl_exec($curl);  \r\n    curl_close($curl);  \r\n    return $result;  \r\n }\r\n for ($i = 0; $i < 1000; $i++) {\r\n    $urls[] = 'http://www.baidu.com/s?wd='. rand(10000, 20000);\r\n }\r\n\r\n$t = microtime(true);\r\n foreach ($urls as $key=>$url) {\r\n    $workers[$key] = new test($url);\r\n    $workers[$key]->start();\r\n }\r\n foreach ($workers as $key=>$worker) {\r\n    while($workers[$key]->isRunning()) {\r\n        usleep(100);  \r\n    }\r\n    if ($workers[$key]->join()) {\r\n//        dump($workers[$key]->result);\r\n    }\r\n }\r\n$e = microtime(true);\r\necho ($e-$t);  \r\n\r\n$t = microtime(true);\r\n foreach ($urls as $key=>$url) {\r\n    model_http_curl_get($url);\r\n//    dump(model_http_curl_get($url));\r\n }\r\n$e = microtime(true);\r\necho ($e-$t);  \r\n\r\n```\r\n\r\nOnly thing dumped is dmesg:\r\n```\r\n in libcurl.so.4.1.1[3f93200000+51000]\r\nphp[3234]: segfault at 10 ip 0000003f9322f62b sp 00007f34a9307f60 error 4 in libcurl.so.4.1.1[3f93200000+51000]\r\nphp[3506]: segfault at 10 ip 0000003f9322f62b sp 00007f269b59cf60 error 4 in libcurl.so.4.1.1[3f93200000+51000]\r\nphp[7678]: segfault at 10 ip 0000003f9322f62b sp 00007f68b5f15f60 error 4 in libcurl.so.4.1.1[3f93200000+51000]\r\nphp[15934]: segfault at 10 ip 0000003f9322f62b sp 00007f379ef6af60 error 4\r\nphp[15938]: segfault at 10 ip 0000003f9322f62b sp 00007f379e0bbf60 error 4 in libcurl.so.4.1.1[3f93200000+51000] in libcurl.so.4.1.1[3f93200000+51000]\r\n\r\nphp[17026]: segfault at 10 ip 0000003f9322f62b sp 00007f64d4da4f60 error 4\r\nphp[17022]: segfault at 10 ip 0000003f9322f62b sp 00007f64d5c53f60 error 4 in libcurl.so.4.1.1[3f93200000+51000] in libcurl.so.4.1.1[3f93200000+51000]\r\n\r\nphp[20748]: segfault at 10 ip 00007f37667f640b sp 00007f3757be9fa0 error 4\r\nphp[20766]: segfault at 10 ip 00007f37667f640b sp 00007f373b5fcfa0 error 4\r\nphp[20751]: segfault at 10 ip 00007f37667f640b sp 00007f3757158fa0 error 4\r\nphp[20754]: segfault at 10 ip 00007f37667f640b sp 00007f37566c7fa0 error 4 in libcurl.so.4.1.1[7f37667c6000+52000]\r\nphp[20760]: segfault at 10 ip 00007f37667f64ad sp 00007f37551a5fa0 error 6 in libcurl.so.4.1.1[7f37667c6000+52000]\r\n in libcurl.so.4.1.1[7f37667c6000+52000] in libcurl.so.4.1.1[7f37667c6000+52000]\r\n\r\n in libcurl.so.4.1.1[7f37667c6000+52000]\r\n\r\nphp[20769]: segfault at 10 ip 00007f37667f640b sp 00007f373abfbfa0 error 4\r\nphp[20742]: segfault at 10 ip 00007f37667f640b sp 00007f375d538fa0 error 4 in libcurl.so.4.1.1[7f37667c6000+52000]\r\n in libcurl.so.4.1.1[7f37667c6000+52000]\r\n```\r\n\r\nIs anything wrong with my code ?\r\nor is this a pthreads' bug "},"comment":{"url":"https://api.github.com/repos/krakjoe/pthreads/issues/comments/131005127","html_url":"https://github.com/krakjoe/pthreads/issues/471#issuecomment-131005127","issue_url":"https://api.github.com/repos/krakjoe/pthreads/issues/471","id":131005127,"user":{"login":"JakeFalcor","id":3183926,"avatar_url":"https://avatars.githubusercontent.com/u/3183926?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeFalcor","html_url":"https://github.com/JakeFalcor","followers_url":"https://api.github.com/users/JakeFalcor/followers","following_url":"https://api.github.com/users/JakeFalcor/following{/other_user}","gists_url":"https://api.github.com/users/JakeFalcor/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeFalcor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeFalcor/subscriptions","organizations_url":"https://api.github.com/users/JakeFalcor/orgs","repos_url":"https://api.github.com/users/JakeFalcor/repos","events_url":"https://api.github.com/users/JakeFalcor/events{/privacy}","received_events_url":"https://api.github.com/users/JakeFalcor/received_events","type":"User","site_admin":false},"created_at":"2015-08-14T07:32:08Z","updated_at":"2015-08-14T07:32:08Z","body":"Master branch of pThreads php is PHP7 compatible, and it probably broken it's compatibility with PHP 5.*. Krakjoe said there were major changes to the codebase.\r\n\r\nLast pthreads version compatible with PHP 5.6 is 2.0.10."}}