mooz / node-icu-charset-detector

A simple binding of ICU character set detection for Node.js
MIT License
86 stars 22 forks source link

Segmentation fault on node.js 0.10.30 #30

Open juhovh opened 8 years ago

juhovh commented 8 years ago

I'm getting the following:

$ node
> var charsetDetector = require("node-icu-charset-detector");
undefined
> var charset = charsetDetector.detectCharset(new Buffer('6d79f668e4', 'hex'));
Segmentation fault (core dumped)
juhovh commented 8 years ago

node-icu-charset-detector version is 0.2.0 and system is Ubuntu.

sffc commented 5 years ago

Still happens on Node.js 6

Another test case:

charsetDetector.detectCharset(Buffer.from("ceb6de4f330820d3ffb18f704b8a42783eb6aa82", "hex"));

Valgrind stack trace:

==20478== Process terminating with default action of signal 11 (SIGSEGV)
==20478==  Access not within mapped region at address 0x10
==20478==    at 0x9BA7290: icu_50::CharsetMatch::getName() const (in /usr/lib64/libicui18n.so.50.1.2)
==20478==    by 0x9848252: CharsetMatch::GetName(Nan::FunctionCallbackInfo<v8::Value> const&) (in /path/to/node_modules/node-icu-charset-detector/build/Release/node-icu-charset-detector.node)
==20478==    by 0x98478B5: Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfo<v8::Value> const&) (in /path/to/node_modules/node-icu-charset-detector/build/Release/node-icu-charset-detector.node)
==20478==    by 0x8A40E1: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) (in /usr/bin/node)
==20478==    by 0x90310D: v8::internal::(anonymous namespace)::HandleApiCallHelper(v8::internal::Isolate*, v8::internal::(anonymous namespace)::BuiltinArguments<(v8::internal::BuiltinExtraArguments)3>) (in /usr/bin/node)
==20478==    by 0x9039AD: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) (in /usr/bin/node)
sffc commented 5 years ago

After some experimentation, I found that this appears to be a bug in ICU4C, not a bug in this wrapper module. The segfault appears to have been fixed in ICU 53. Upgrading your ICU4C installation to ICU 53 or later should fix the issue.