Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Dynamic linking breaks if locale is not english #93

epeli opened this Issue Dec 10, 2012 · 3 comments


None yet
3 participants

epeli commented Dec 10, 2012

I'm trying to link to libc on fairly standard Ubuntu Quantal installation
with finnish translations and locales.

var ffi = require("ffi");
var libc = ffi.Library("libc", {
  "setlocale": [ "string", ["int", "string"] ]

And I'm getting following error:

Dynamic Linking Error: /usr/lib/i386-linux-gnu/libc.so: virheellinen ELF-otsikko"

This works fine if I change the language to english from gnome-control-center.

The reason for this is very obvious after looking at this:


It assumes that the error message is always in english, but unfortunaly that's
not the case. For example I have here "virheellinen ELF-otsikko" instead of
"invalid ELF header".

I'm running into this only when I'm using node-webkit. Plain node seems to be
unaffected for some reason. It might be because node-webkit does some extra
locale digging on startup:
https://github.com/rogerwang/node-webkit/wiki/Play-with-window (the last section).

But nevertheless node-ffi should not never rely on error message strings which
might get translated. The reason for this implementation seems to be the lack of
proper error codes in dlopen(3) API, but I hope we could figure out some more
robust implementation for this.


TooTallNate commented Dec 15, 2012

Interesting find! I suppose we're gonna have to find a way to fix this. Patches welcome of course. Figuring out how to add a test case for this will be interesting as well...


unbornchikken commented Aug 6, 2015

@TooTallNate if we match

/^(([^ \t()])+\.so([^ \t:()])*):([ \t])*/

without the English text, and then do the retry, it would resolve that issue. If it match another dlopen error accidentally, then what happens? We get another error, and nothing else, we could throw the original one, and everything works like before.

@unbornchikken unbornchikken referenced this issue Aug 6, 2015


fix of #93 #224


TooTallNate commented Sep 4, 2015

Fixed in v2.0.0.

@TooTallNate TooTallNate closed this Sep 4, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment