payload: {"action":"created","issue":{"url":"https://api.github.com/repos/arirusso/alsa-rawmidi/issues/7","repository_url":"https://api.github.com/repos/arirusso/alsa-rawmidi","labels_url":"https://api.github.com/repos/arirusso/alsa-rawmidi/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/arirusso/alsa-rawmidi/issues/7/comments","events_url":"https://api.github.com/repos/arirusso/alsa-rawmidi/issues/7/events","html_url":"https://github.com/arirusso/alsa-rawmidi/issues/7","id":305412907,"node_id":"MDU6SXNzdWUzMDU0MTI5MDc=","number":7,"title":"Segfaults on Ubuntu Xenial","user":{"login":"Space-Ed","id":6799598,"node_id":"MDQ6VXNlcjY3OTk1OTg=","avatar_url":"https://avatars3.githubusercontent.com/u/6799598?v=4","gravatar_id":"","url":"https://api.github.com/users/Space-Ed","html_url":"https://github.com/Space-Ed","followers_url":"https://api.github.com/users/Space-Ed/followers","following_url":"https://api.github.com/users/Space-Ed/following{/other_user}","gists_url":"https://api.github.com/users/Space-Ed/gists{/gist_id}","starred_url":"https://api.github.com/users/Space-Ed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Space-Ed/subscriptions","organizations_url":"https://api.github.com/users/Space-Ed/orgs","repos_url":"https://api.github.com/users/Space-Ed/repos","events_url":"https://api.github.com/users/Space-Ed/events{/privacy}","received_events_url":"https://api.github.com/users/Space-Ed/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-03-15T04:36:23Z","updated_at":"2019-02-15T07:56:23Z","closed_at":null,"author_association":"NONE","body":"libasound2 & libasound2-dev installed \r\n```\r\n$ ruby --version\r\nruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]\r\n\r\n$ amidi -l\r\nDir Device    Name\r\nIO  hw:2,0    Virtual Raw MIDI (16 subdevices)\r\nIO  hw:2,1    Virtual Raw MIDI (16 subdevices)\r\nIO  hw:2,2    Virtual Raw MIDI (16 subdevices)\r\nIO  hw:2,3    Virtual Raw MIDI (16 subdevices)\r\n```\r\nGemfile\r\n```\r\ngem \"alsa-rawmidi\"\r\n```\r\nalsa-midi.rb\r\n```\r\nrequire \"alsa-rawmidi\"\r\nAlsaRawMIDI::Device.all\r\n```\r\n\r\n```\r\n$ ruby alsa-midi.rb\r\nalsa-rawmidi/api.rb:407: [BUG] Segmentation fault at 0xffffffff9bf5a098\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/arirusso/alsa-rawmidi/issues/comments/463942830","html_url":"https://github.com/arirusso/alsa-rawmidi/issues/7#issuecomment-463942830","issue_url":"https://api.github.com/repos/arirusso/alsa-rawmidi/issues/7","id":463942830,"node_id":"MDEyOklzc3VlQ29tbWVudDQ2Mzk0MjgzMA==","user":{"login":"fukuchi","id":637330,"node_id":"MDQ6VXNlcjYzNzMzMA==","avatar_url":"https://avatars3.githubusercontent.com/u/637330?v=4","gravatar_id":"","url":"https://api.github.com/users/fukuchi","html_url":"https://github.com/fukuchi","followers_url":"https://api.github.com/users/fukuchi/followers","following_url":"https://api.github.com/users/fukuchi/following{/other_user}","gists_url":"https://api.github.com/users/fukuchi/gists{/gist_id}","starred_url":"https://api.github.com/users/fukuchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fukuchi/subscriptions","organizations_url":"https://api.github.com/users/fukuchi/orgs","repos_url":"https://api.github.com/users/fukuchi/repos","events_url":"https://api.github.com/users/fukuchi/events{/privacy}","received_events_url":"https://api.github.com/users/fukuchi/received_events","type":"User","site_admin":false},"created_at":"2019-02-15T07:56:23Z","updated_at":"2019-02-15T07:56:23Z","author_association":"NONE","body":"Hi,\r\n\r\nHere's a quick-and-dirty hack to avoid the segmentation fault:\r\n\r\n```\r\n--- ./api.rb\t2019-02-15 16:50:37.218105977 +0900\r\n+++ /tmp/api.rb\t2019-02-15 16:50:30.766584839 +0900\r\n@@ -330,9 +330,9 @@\r\n       # @param [Proc] block\r\n       # @return [Integer]\r\n       def open(id, &block)\r\n-        handle_pointer = FFI::MemoryPointer.new(FFI.type_size(:int))\r\n+        handle_pointer = FFI::MemoryPointer.new(FFI.type_size(:ulong))\r\n         yield(handle_pointer)\r\n-        handle_pointer.read_int\r\n+        handle_pointer.read_ulong\r\n       end\r\n \r\n     end\r\n@@ -424,9 +424,9 @@\r\n       # @param [Integer] soundcard_id\r\n       # @return [Integer]\r\n       def get_handle(soundcard_id)\r\n-        handle_pointer = FFI::MemoryPointer.new(FFI.type_size(:int))\r\n+        handle_pointer = FFI::MemoryPointer.new(FFI.type_size(:ulong))\r\n         API.snd_ctl_open(handle_pointer, get_name(soundcard_id), 0)\r\n-        handle_pointer.read_int\r\n+        handle_pointer.read_ulong\r\n       end\r\n \r\n     end\r\n```\r\n\r\nThis works with Ubuntu 18.04 as far as I tested.\r\n\r\nWhile I'm not familiar with the implementation of Ruby's FFI, the problem behind this issue is that the latest alsa-rawmidi uses 'int' to store the pointer to a snd_ctl_t.\r\n\r\nThe patch above may have problem on 32-bit environment and/or old Linux distributions because probably they uses 32-bit runtimes instead 64-bit."}}
other: {"actor":{"display_login":"fukuchi"}}