{"id":210,"date":"2015-09-23T19:31:10","date_gmt":"2015-09-24T03:31:10","guid":{"rendered":"http:\/\/nramkumar.org\/tech\/?p=210"},"modified":"2015-10-11T14:05:48","modified_gmt":"2015-10-11T22:05:48","slug":"mhddfs-crash-with-ubuntu-14-04","status":"publish","type":"post","link":"https:\/\/nramkumar.org\/tech\/blog\/2015\/09\/23\/mhddfs-crash-with-ubuntu-14-04\/","title":{"rendered":"mhddfs crash with Ubuntu 14.04"},"content":{"rendered":"<p>After a long period of contemplation and indecision, I upgraded the hardware on my Ubuntu Home Server last weekend. I&#8217;ll write a separate post about my adventures there (mostly self-inflicted).<\/p>\n<p>As part of the upgrade, I also clean installed Ubuntu Server 14.04 LTS. I picked up mhddfs by doing <code>sudo apt-get install mhddfs<\/code> to continue the same excellent mhddfs+snapraid setup that I have been using for the past few years to manage my storage &#8211; you can find details <a href=\"https:\/\/nramkumar.org\/tech\/blog\/2014\/05\/27\/disk-pooling-and-failure-tolerance-for-ubuntu-nas-mhddfs-and-snapraid\/\" target=\"_blank\">here<\/a>. Everything seemed to be working fine but today morning, I found that all my samba shares on the server had vanished!<\/p>\n<p>I tried to figure out what was going on and found that the mhddfs mount point was no longer accessible &#8211; cd \/storage showed the error <code>The transport endpoint is not connected<\/code>.<\/p>\n<p>I quickly did <code>ps auxw | grep mhddfs<\/code> and saw that mhddfs was no longer running. \/var\/log\/kern.log showed that mhddfs had quit with a segfault &#8211; uh-oh!<\/p>\n<p><code>mhddfs[11861]: segfault at 0 ip 0000000000404750 sp 00007f1100ff8a40 error 4 in mhddfs[400000+b000]<\/code><\/p>\n<p>A quick search for &#8220;mhddfs transport endpoint is not connected&#8221; lead me to <a href=\"http:\/\/stackoverflow.com\/questions\/24966676\/transport-endpoint-is-not-connected\" target=\"_blank\">this q&amp;a<\/a> and in turn to this fix for the issue <a href=\"https:\/\/github.com\/vdudouyt\/mhddfs-nosegfault\" target=\"_blank\">here.<\/a> While this is a fine fix, I was intrigued to figure out why the crash was happening in the first place &#8211; the fact that it started from 1.39 and that it seems to be fixed by replacing the uthash code with a different implementation narrowed down the places to look a lot.<\/p>\n<p>Looking at this <a href=\"https:\/\/github.com\/crass\/mhddfs\/commit\/c62547d50a574ed9e3b04a8533be1c350b08c2ea\" target=\"_blank\">commit<\/a> that was the only change from 1.38 to 1.39, I didn&#8217;t find anything obviously wrong at first. But then I decided to take a closer look at <code>HASH_CLEAR<\/code> and it struck me that the issue is a use after free &#8211; the code in question <a href=\"https:\/\/github.com\/crass\/mhddfs\/blob\/c62547d50a574ed9e3b04a8533be1c350b08c2ea\/src\/main.c#L246-L251\" target=\"_blank\">here<\/a> would access the node after it had been free&#8217;d due to the call to <code>HASH_CLEAR<\/code>.<\/p>\n<p>I&#8217;ve forked the github repo for mhddfs and patched it with a fix &#8211; running that for the past few hours and so far everything seems to work fine. Here&#8217;s the <a href=\"https:\/\/github.com\/ram-nat\/mhddfs\/commit\/26d0f119eaa7e3ffaaf330bf29672e13471cb091\" target=\"_blank\">link to the fix<\/a> and here&#8217;s the <a href=\"https:\/\/github.com\/ram-nat\/mhddfs\/blob\/master\/mhddfs?raw=true\">pre-built binary for Ubuntu Server 14.04 LTS<\/a><\/p>\n<p>I&#8217;ll update this post in a couple of weeks on if\/how my patch is working.<\/p>\n<p><strong>Update 9\/27\/2015\u00a0<\/strong>My home server has been running mhddfs with this change without issues for 5 days now.<\/p>\n<p><strong>Update 10\/11\/2015\u00a0<\/strong>My home server has been running mhddfs with this change without issues for 20 days now.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After a long period of contemplation and indecision, I upgraded the hardware on my Ubuntu Home Server last weekend. I&#8217;ll write a separate post about my adventures there (mostly self-inflicted). As part of the upgrade, I also clean installed Ubuntu Server 14.04 LTS. I picked up mhddfs by doing sudo apt-get install mhddfs to continue&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54,41,6],"tags":[78,76,79,77],"class_list":["post-210","post","type-post","status-publish","format-standard","hentry","category-mhddfs","category-nas","category-ubuntu","tag-mhddfs-1-39-crash","tag-mhddfs-crash","tag-mhddfs-the-transport-endpoint-is-not-connected","tag-ubuntu-14-04-mhddfs-crash"],"_links":{"self":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/comments?post=210"}],"version-history":[{"count":8,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/210\/revisions"}],"predecessor-version":[{"id":246,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/210\/revisions\/246"}],"wp:attachment":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/media?parent=210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/categories?post=210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/tags?post=210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}