Thanks for reporting that. Although I don't have easy access to that platform, I simulated the problem on FreeBSD 11 x86-64 and came up with the attached patch, which I installed into the Emacs master branch. Please give it a try if you can, and let me know either way. I doubt whether this patch will apply to Emacs 25 and have not investigated the details there.