{"action":"opened","issue":{"url":"https://api.github.com/repos/plicease/FFI-Platypus/issues/51","labels_url":"https://api.github.com/repos/plicease/FFI-Platypus/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/plicease/FFI-Platypus/issues/51/comments","events_url":"https://api.github.com/repos/plicease/FFI-Platypus/issues/51/events","html_url":"https://github.com/plicease/FFI-Platypus/issues/51","id":62610749,"number":51,"title":"Documentation: FAQ: pthreads and Net/FreeBSD","user":{"login":"plicease","id":354009,"avatar_url":"https://avatars.githubusercontent.com/u/354009?v=3","gravatar_id":"","url":"https://api.github.com/users/plicease","html_url":"https://github.com/plicease","followers_url":"https://api.github.com/users/plicease/followers","following_url":"https://api.github.com/users/plicease/following{/other_user}","gists_url":"https://api.github.com/users/plicease/gists{/gist_id}","starred_url":"https://api.github.com/users/plicease/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plicease/subscriptions","organizations_url":"https://api.github.com/users/plicease/orgs","repos_url":"https://api.github.com/users/plicease/repos","events_url":"https://api.github.com/users/plicease/events{/privacy}","received_events_url":"https://api.github.com/users/plicease/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/plicease/FFI-Platypus/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-18T07:13:11Z","updated_at":"2015-03-18T07:13:11Z","closed_at":null,"body":"Libraries that use pthreads on Free/NetBSD may crash, see:\r\n\r\nhttps://github.com/calid/zmq-ffi/issues/13\r\n\r\nAt the moment this does not seem to be a FFI / Platypus issue, but a general Perl issue, but it is frustrating if you see the crashes and do not know what it is, so this should be documented perhaps as a FAQ or Trouble Shooting entry.\r\n\r\nAlso consider adding an option (off by default) for `Module::Build::FFI` to set LD_PRELOAD to pthreads on platforms that need it when running `./Build test`.  I am a bit leery of this because without a big DANGER WILL ROBINSON statement module using Foo::FFI it will be passing the buck to the module and the user using Foo::FFI.  Perhaps if coupled with detection code that detects if pthreads have been loaded with a helpful diagnostic this could be workable.\r\n\r\n```perl\r\nuse strict;\r\nuse warnings;\r\nuse 5.010;\r\nuse FFI::Platypus;\r\n\r\nmy $ffi = FFI::Platypus->new;\r\n$ffi->find_lib( lib => 'pthread' );\r\n\r\n$ffi->attach( pthread_self => [] => 'opaque' );\r\n\r\nif(pthread_self() == -1)\r\n{\r\n  warn 'pthreads were not initalized';\r\n}\r\nelse\r\n{\r\n  say pthread_self();\r\n}\r\n```\r\n\r\nhttps://rt.perl.org/Public/Bug/Display.html?id=122906\r\nhttp://stackoverflow.com/questions/13587325/threads-vs-pthread-in-perl"}}