mscdex / sipster

A pjsip/pjsua2 binding for node.js
MIT License
190 stars 48 forks source link

Installation on OSX El Capitan fails #21

Open vgire opened 8 years ago

vgire commented 8 years ago

Hello, I am trying to move from python's pjsip biddings to sipster, but I get the following error:

$ npm install sipster
> sipster@0.1.0 install /Users/vincentgire/Documents/Projects/sensout/proto/phone/node_modules/sipster
> node-gyp rebuild

  CXX(target) Release/obj.target/sipster/src/binding.o
../src/binding.cc:6:10: fatal error: 'pjsua2.hpp' file not found
#include <pjsua2.hpp>
         ^
1 error generated.
make: *** [Release/obj.target/sipster/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/vincentgire/Documents/Projects/sensout/proto/phone/node_modules/sipster
gyp ERR! node -v v5.4.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok 
npm WARN EPACKAGEJSON phone@1.0.0 No description
npm WARN EPACKAGEJSON phone@1.0.0 No repository field.
npm WARN EPACKAGEJSON phone@1.0.0 No license field.
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "sipster"
npm ERR! node v5.4.1
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE

npm ERR! sipster@0.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sipster@0.1.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sipster package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls sipster
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/vincentgire/Documents/Projects/sensout/proto/phone/npm-debug.log

It seems the pjsua library headers are not found but pkg-config does recognize pjproject as being installed.

My system is OSX El Capitan 10.11.1 with:

$ node -v
v5.4.1

$ npm -v
3.3.12

$ pkg-config --version
0.28

$ pkg-config --modversion libpjproject
2.4.5

I have installed pjsip with:

tar xvjf pjproject-2.4.5.tar.bz2
cd pjproject-2.4.5
./configure --enable-shared && make dep && make clean && make && make install

Any help would be really appreciated.

Thanks

mscdex commented 8 years ago

What does pkg-config --cflags libpjproject show? Is pjsua2.hpp in the include directory shown in that output?

vgire commented 8 years ago

Thank you for your quick reply. I have:

$ pkg-config --cflags libpjproject
-DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -fPIC -I/usr/local/include

And:

$ cd /usr/local/include/; ls | grep pjsua
pjsua
pjsua-lib
pjsua.h
pjsua2
pjsua2.hpp
mscdex commented 8 years ago

Ok, let's verify the compiler flags. Try adding --loglevel silly to your npm install command line and post the last compiler command line before the error.

vgire commented 8 years ago

Here you go !

$ npm install sipster --loglevel silly
...
c++ '-DNODE_GYP_MODULE_NAME=sipster' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/Users/vincentgire/.node-gyp/5.4.1/include/node -I/Users/vincentgire/.node-gyp/5.4.1/src -I/Users/vincentgire/.node-gyp/5.4.1/deps/uv/include -I/Users/vincentgire/.node-gyp/5.4.1/deps/v8/include -I../src -I../../nan  -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++0x -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-strict-aliasing -fexceptions -frtti -MMD -MF ./Release/.deps/Release/obj.target/sipster/src/binding.o.d.raw  -c -o Release/obj.target/sipster/src/binding.o ../src/binding.cc
../src/binding.cc:6:10: fatal error: 'pjsua2.hpp' file not found
#include <pjsua2.hpp>
         ^
1 error generated.
...

Maybe -I../../nan ?

mscdex commented 8 years ago

It looks like it has almost completely ignored the cflags defined in binding.gyp. Weird....

vgire commented 8 years ago

Following your guidance, I think I've made a step towards resolution.

I've found a cflags ignored issue for node-gyp on OSX and a solution.

After adding '<!@(pkg-config --cflags libpjproject)' to the OTHER_CFLAGS field in binding.gyp:

'OTHER_CFLAGS': [
  '-fexceptions',
  '-frtti',
  '<!@(pkg-config --cflags libpjproject)'
]

I get:

$ npm install sipster

> sipster@0.1.0 install /Users/vincentgire/Documents/Projects/sensout/proto/phone/node_modules/sipster
> node-gyp rebuild

  CXX(target) Release/obj.target/sipster/src/binding.o
  CXX(target) Release/obj.target/sipster/src/SIPSTERAccount.o
  CXX(target) Release/obj.target/sipster/src/SIPSTERCall.o
  CXX(target) Release/obj.target/sipster/src/SIPSTERMedia.o
  CXX(target) Release/obj.target/sipster/src/SIPSTERTransport.o
  SOLINK_MODULE(target) Release/sipster.node
phone@1.0.0 /Users/vincentgire/Documents/Projects/sensout/proto/phone
└── sipster@0.1.0  (git+https://github.com/vgire/sipster.git#a3320567abf1ba20497c665573280d2bf6cf7923)

But now, when I try to require sipster, I get:

$ node -e "require('sipster')"
Segmentation fault: 11

Something must still be wrong in the build/bundle process. Here is the trace of the build (where the error used to be):

  c++ '-DNODE_GYP_MODULE_NAME=sipster' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/Users/vincentgire/.node-gyp/5.5.0/include/node -I/Users/vincentgire/.node-gyp/5.5.0/src -I/Users/vincentgire/.node-gyp/5.5.0/deps/uv/include -I/Users/vincentgire/.node-gyp/5.5.0/deps/v8/include -I../src -I../../nan  -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++0x -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-strict-aliasing -fexceptions -frtti -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -fPIC -I/usr/local/include -MMD -MF ./Release/.deps/Release/obj.target/sipster/src/binding.o.d.raw  -c -o Release/obj.target/sipster/src/binding.o ../src/binding.cc
  c++ '-DNODE_GYP_MODULE_NAME=sipster' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/Users/vincentgire/.node-gyp/5.5.0/include/node -I/Users/vincentgire/.node-gyp/5.5.0/src -I/Users/vincentgire/.node-gyp/5.5.0/deps/uv/include -I/Users/vincentgire/.node-gyp/5.5.0/deps/v8/include -I../src -I../../nan  -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++0x -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-strict-aliasing -fexceptions -frtti -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -fPIC -I/usr/local/include -MMD -MF ./Release/.deps/Release/obj.target/sipster/src/SIPSTERAccount.o.d.raw  -c -o Release/obj.target/sipster/src/SIPSTERAccount.o ../src/SIPSTERAccount.cc
  c++ '-DNODE_GYP_MODULE_NAME=sipster' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/Users/vincentgire/.node-gyp/5.5.0/include/node -I/Users/vincentgire/.node-gyp/5.5.0/src -I/Users/vincentgire/.node-gyp/5.5.0/deps/uv/include -I/Users/vincentgire/.node-gyp/5.5.0/deps/v8/include -I../src -I../../nan  -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++0x -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-strict-aliasing -fexceptions -frtti -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -fPIC -I/usr/local/include -MMD -MF ./Release/.deps/Release/obj.target/sipster/src/SIPSTERCall.o.d.raw  -c -o Release/obj.target/sipster/src/SIPSTERCall.o ../src/SIPSTERCall.cc
  c++ '-DNODE_GYP_MODULE_NAME=sipster' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/Users/vincentgire/.node-gyp/5.5.0/include/node -I/Users/vincentgire/.node-gyp/5.5.0/src -I/Users/vincentgire/.node-gyp/5.5.0/deps/uv/include -I/Users/vincentgire/.node-gyp/5.5.0/deps/v8/include -I../src -I../../nan  -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++0x -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-strict-aliasing -fexceptions -frtti -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -fPIC -I/usr/local/include -MMD -MF ./Release/.deps/Release/obj.target/sipster/src/SIPSTERMedia.o.d.raw  -c -o Release/obj.target/sipster/src/SIPSTERMedia.o ../src/SIPSTERMedia.cc
  c++ '-DNODE_GYP_MODULE_NAME=sipster' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/Users/vincentgire/.node-gyp/5.5.0/include/node -I/Users/vincentgire/.node-gyp/5.5.0/src -I/Users/vincentgire/.node-gyp/5.5.0/deps/uv/include -I/Users/vincentgire/.node-gyp/5.5.0/deps/v8/include -I../src -I../../nan  -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++0x -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-strict-aliasing -fexceptions -frtti -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -fPIC -I/usr/local/include -MMD -MF ./Release/.deps/Release/obj.target/sipster/src/SIPSTERTransport.o.d.raw  -c -o Release/obj.target/sipster/src/SIPSTERTransport.o ../src/SIPSTERTransport.cc
  c++ -bundle -undefined dynamic_lookup -Wl,-search_paths_first -mmacosx-version-min=10.5 -arch x86_64 -L./Release  -o Release/sipster.node Release/obj.target/sipster/src/binding.o Release/obj.target/sipster/src/SIPSTERAccount.o Release/obj.target/sipster/src/SIPSTERCall.o Release/obj.target/sipster/src/SIPSTERMedia.o Release/obj.target/sipster/src/SIPSTERTransport.o -L/usr/local/lib -lpjsua2 -lstdc++ -lpjsua -lpjsip-ua -lpjsip-simple -lpjsip -lpjmedia-codec -lpjmedia -lpjmedia-videodev -lpjmedia-audiodev -lpjnath -lpjlib-util -lsrtp -lresample -lgsmcodec -lspeex -lilbccodec -lg7221codec -lportaudio -lpj -lssl -lcrypto -lm -lpthread -framework CoreAudio -framework CoreAudio -framework CoreServices -framework AudioUnit -framework AudioToolbox -framework Foundation -framework AppKit -framework QTKit -framework QuartzCore -framework OpenGL

Any ideas ? Thank you very much for your help

mscdex commented 8 years ago

For the segfault, you might try executing node under gdb or lldb and get a backtrace when it crashes. I don't know why it would do that offhand though.

vgire commented 8 years ago

Same segfault on a fresh install of OSX El Capitan (but no need to modify binding.gyp anymore). Will try to get the backtrace later.

vgire commented 8 years ago
$ lldb -- node test.js
(lldb) target create "node"
Current executable set to 'node' (x86_64).
(lldb) settings set -- target.run-args  "test.js"
(lldb) run
Process 12020 launched: '/usr/local/bin/node' (x86_64)
Process 12020 stopped
* thread #1: tid = 0x18df1, 0x00007fff99361152 libsystem_c.dylib`strlen + 18, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff99361152 libsystem_c.dylib`strlen + 18
libsystem_c.dylib`strlen:
->  0x7fff99361152 <+18>: pcmpeqb (%rdi), %xmm0
    0x7fff99361156 <+22>: pmovmskb %xmm0, %esi
    0x7fff9936115a <+26>: andq   $0xf, %rcx
    0x7fff9936115e <+30>: orq    $-0x1, %rax

where test.js is simply:

var sipster = require('sipster');

I must admit that it makes no sens to me. Any hint on how to solve this ? Thank you

mscdex commented 8 years ago

Do you get another lldb prompt after that where you could type bt or something?

I don't have a mac readily accessible at the moment unfortunately.

vgire commented 8 years ago

Yes I do (sorry, I'm completely new to node native addon debugging). Here is the full backtrace:

$ lldb -- node test.js
(lldb) target create "node"
Current executable set to 'node' (x86_64).
(lldb) settings set -- target.run-args  "test.js"
(lldb) run
Process 12070 launched: '/usr/local/bin/node' (x86_64)
Process 12070 stopped
* thread #1: tid = 0x1bc2c, 0x00007fff99361152 libsystem_c.dylib`strlen + 18, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff99361152 libsystem_c.dylib`strlen + 18
libsystem_c.dylib`strlen:
->  0x7fff99361152 <+18>: pcmpeqb (%rdi), %xmm0
    0x7fff99361156 <+22>: pmovmskb %xmm0, %esi
    0x7fff9936115a <+26>: andq   $0xf, %rcx
    0x7fff9936115e <+30>: orq    $-0x1, %rax
(lldb) bt
* thread #1: tid = 0x1bc2c, 0x00007fff99361152 libsystem_c.dylib`strlen + 18, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00007fff99361152 libsystem_c.dylib`strlen + 18
    frame #1: 0x00000001001309a2 node`v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) + 98
    frame #2: 0x00000001025eb308 sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] Nan::imp::Factory<v8::String>::New(value=0x0000000000000000, length=-1) + 23 at nan_implementation_12_inl.h:264
    frame #3: 0x00000001025eb2f1 sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] Nan::imp::Factory<v8::String>::return_t Nan::New<v8::String, char const*>(arg0=0x0000000000000000) at nan_new.h:208
    frame #4: 0x00000001025eb2f1 sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] Nan::New(value=0x0000000000000000) at nan_new.h:313
    frame #5: 0x00000001025eb2f1 sipster.node`EPVersion(info=0x00007fff5fbfefa8) + 488 at binding.cc:535
    frame #6: 0x00000001025fd588 sipster.node`Nan::imp::FunctionCallbackWrapper(info=0x00007fff5fbfefe8) + 131 at nan_callbacks_12_inl.h:174
    frame #7: 0x000000010016139f node`v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) + 159
    frame #8: 0x000000010018aa25 node`v8::internal::MaybeHandle<v8::internal::Object> v8::internal::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::(anonymous namespace)::BuiltinArguments<(v8::internal::BuiltinExtraArguments)1>&) + 1253
    frame #9: 0x000000010018d291 node`v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) + 65
    frame #10: 0x000032c8cbd0839b
    frame #11: 0x000032c8cbe531aa
    frame #12: 0x000032c8cbd34a9c
    frame #13: 0x000032c8cbe4d37c
    frame #14: 0x000032c8cbe45c4b
    frame #15: 0x000032c8cbe42a7b
    frame #16: 0x000032c8cbe383ee
    frame #17: 0x000032c8cbe4e253
    frame #18: 0x000032c8cbe4e02e
    frame #19: 0x000032c8cbe4d9bf
    frame #20: 0x000032c8cbd34a9c
    frame #21: 0x000032c8cbe4d37c
    frame #22: 0x000032c8cbe45c4b
    frame #23: 0x000032c8cbe42a7b
    frame #24: 0x000032c8cbe383ee
    frame #25: 0x000032c8cbe37e06
    frame #26: 0x000032c8cbd3b545
    frame #27: 0x000032c8cbd38eb5
    frame #28: 0x000032c8cbd31bdd
    frame #29: 0x000032c8cbd15282
    frame #30: 0x00000001002c3d00 node`v8::internal::Invoke(bool, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) + 768
    frame #31: 0x00000001002c379c node`v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, bool) + 364
    frame #32: 0x0000000100147dea node`v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 282
    frame #33: 0x0000000100657cdf node`node::LoadEnvironment(node::Environment*) + 486
    frame #34: 0x000000010065913f node`node::Start(int, char**) + 502
    frame #35: 0x0000000100000d34 node`start + 52
(lldb) 
mscdex commented 8 years ago

Huh.... it looks like it's returning null when querying the pjsip version string. I've never seen that happen.

mscdex commented 8 years ago

I think null checks like this should be in nan anyway, I will send them a PR. In the meantime, feel free to comment out these lines for now. That should fix this particular problem.

vgire commented 8 years ago

I tried commenting these lines but now I get:

$ lldb -- node test.js
(lldb) target create "node"
Current executable set to 'node' (x86_64).
(lldb) settings set -- target.run-args  "test.js"
(lldb) run
Process 12341 launched: '/usr/local/bin/node' (x86_64)
Process 12341 stopped
* thread #1: tid = 0x201c4, 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] __gnu_cxx::__exchange_and_add(__val=-1) at atomicity.h:51, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8)
    frame #0: 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] __gnu_cxx::__exchange_and_add(__val=-1) at atomicity.h:51
   48   #ifdef _GLIBCXX_ATOMIC_BUILTINS
   49     static inline _Atomic_word 
   50     __exchange_and_add(volatile _Atomic_word* __mem, int __val)
-> 51     { return __sync_fetch_and_add(__mem, __val); }
   52   
   53     static inline void
   54     __atomic_add(volatile _Atomic_word* __mem, int __val)
(lldb) bt
* thread #1: tid = 0x201c4, 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] __gnu_cxx::__exchange_and_add(__val=-1) at atomicity.h:51, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8)
  * frame #0: 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] __gnu_cxx::__exchange_and_add(__val=-1) at atomicity.h:51
    frame #1: 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] __gnu_cxx::__exchange_and_add_dispatch(__val=-1) at atomicity.h:84
    frame #2: 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] std::string::_Rep::_M_dispose(std::allocator<char> const&) at basic_string.h:236
    frame #3: 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] std::string::~() at basic_string.h:493
    frame #4: 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] std::string::~() at basic_string.h:493
    frame #5: 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] pj::Version::~Version() at types.hpp:209
    frame #6: 0x00000001024eb56c sipster.node`EPVersion(Nan::FunctionCallbackInfo<v8::Value> const&) [inlined] pj::Version::~Version() at types.hpp:209
    frame #7: 0x00000001024eb56c sipster.node`EPVersion(info=<unavailable>) + 851 at binding.cc:544
    frame #8: 0x00000001024fd598 sipster.node`Nan::imp::FunctionCallbackWrapper(info=0x00007fff5fbfeff8) + 131 at nan_callbacks_12_inl.h:174
    frame #9: 0x000000010016139f node`v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) + 159
    frame #10: 0x000000010018aa25 node`v8::internal::MaybeHandle<v8::internal::Object> v8::internal::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::(anonymous namespace)::BuiltinArguments<(v8::internal::BuiltinExtraArguments)1>&) + 1253
    frame #11: 0x000000010018d291 node`v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) + 65
    frame #12: 0x0000301c3000839b
    frame #13: 0x0000301c301531aa
    frame #14: 0x0000301c30034a9c
    frame #15: 0x0000301c3014d37c
    frame #16: 0x0000301c30145c4b
    frame #17: 0x0000301c30142a7b
    frame #18: 0x0000301c301383ee
    frame #19: 0x0000301c3014e253
    frame #20: 0x0000301c3014e02e
    frame #21: 0x0000301c3014d9bf
    frame #22: 0x0000301c30034a9c
    frame #23: 0x0000301c3014d37c
    frame #24: 0x0000301c30145c4b
    frame #25: 0x0000301c30142a7b
    frame #26: 0x0000301c301383ee
    frame #27: 0x0000301c30137e06
    frame #28: 0x0000301c3003b545
    frame #29: 0x0000301c30038eb5
    frame #30: 0x0000301c30031bdd
    frame #31: 0x0000301c30015282
    frame #32: 0x00000001002c3d00 node`v8::internal::Invoke(bool, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) + 768
    frame #33: 0x00000001002c379c node`v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, bool) + 364
    frame #34: 0x0000000100147dea node`v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 282
    frame #35: 0x0000000100657cdf node`node::LoadEnvironment(node::Environment*) + 486
    frame #36: 0x000000010065913f node`node::Start(int, char**) + 502
    frame #37: 0x0000000100000d34 node`start + 52
(lldb) 

(Sorry I am not being more helpful).

mscdex commented 8 years ago

I'm not sure what's happening now, it looks like something internal in the standard C library.

I've never tried clang/llvm before, only gcc.

vgire commented 8 years ago

Ok, I've made some progress with:

$ brew install gcc
$ env CXX=gcc-5 npm install git+https://github.com/vgire/sipster.git

And now:

$ node -e "require('sipster')"

does not crash anymore, but:

$ node -e "require('sipster').init()"
12:31:36.458 os_core_unix.c !pjlib 2.4.5 for POSIX initialized
12:31:36.461 sip_endpoint.c  .Creating endpoint instance...
12:31:36.462          pjlib  .select() I/O Queue created (0x101809ad8)
12:31:36.462 sip_endpoint.c  .Module "mod-msg-print" registered
12:31:36.462 sip_transport.  .Transport manager created.
12:31:36.462   pjsua_core.c  .PJSUA state changed: NULL --> CREATED
libc++abi.dylib: terminating with uncaught exception of type pj::Error
Sat-02 Error creating log file: No such file or directory [status=120002]Sat-02 pjsua_init(&ua_cfg, &log_cfg, &med_cfg) error: No such file or directory (status=120002) [../src/pjsua2/endpoint.cpp:1284]Abort trap: 6
mscdex commented 8 years ago

Try passing in an empty object to init().

vgire commented 8 years ago

Same error:

$ node -e "require('sipster').init({})"
19:40:31.870 os_core_unix.c !pjlib 2.4.5 for POSIX initialized
19:40:31.873 sip_endpoint.c  .Creating endpoint instance...
19:40:31.873          pjlib  .select() I/O Queue created (0x1038124d8)
19:40:31.874 sip_endpoint.c  .Module "mod-msg-print" registered
19:40:31.874 sip_transport.  .Transport manager created.
19:40:31.874   pjsua_core.c  .PJSUA state changed: NULL --> CREATED
libc++abi.dylib: terminating with uncaught exception of type pj::Error
Sat-02 Error creating log file: No such file or directory [status=120002]Sat-02 pjsua_init(&ua_cfg, &log_cfg, &med_cfg) error: No such file or directory (status=120002) [../src/pjsua2/endpoint.cpp:1284]Abort trap: 6
mscdex commented 8 years ago

I know you're doing this on OS X, but I just found out that at least on Ubuntu the default g++ (5.x) compiler causes issues (I still haven't found out why). I installed and had no problems with g++ 4.9 however, so perhaps you might give that a shot if we're encountering the same issue...

vgire commented 8 years ago

What kind of issue do you get with g++ (5.x) ?

I tried with gcc 4.9:

$ brew install homebrew/versions/gcc49
$ env CXX=gcc-4.9 npm install git+https://github.com/vgire/sipster.git

but this times, it crashes even before calling init():

$ node -e "require('sipster')"
$ Segmentation fault: 11
mscdex commented 8 years ago

After more digging it seems like the segfaults I was seeing were due to the new (C++11) ABI introduced in g++ 5. I recompiled and installed pjsip 2.4.5 and then rebuilt sipster and all was well again. I guess I had compiled pjsip with a pre-5.0 version of g++ and that didn't play well with the sipster built with g++ 5. I wish they could have provided a compile-time or link-time warning though...

To see if you're running into the same problem you can try adding -D_GLIBCXX_USE_CXX11_ABI=0 to your CXXFLAGS when building/installing sipster. I'm assuming you didn't build pjsip from source, in which case it's possible that the prebuilt version you installed was either not built with g++ 5 or had the new ABI disabled.

vgire commented 8 years ago

I installed pjsip from source with:

$ tar xvjf pjproject-2.4.5.tar.bz2
$ cd pjproject-2.4.5
$ ./configure --enable-shared && make dep && make clean && make && make install

so it was compiled with clang/llvm. I tried to rebuild it with gcc but it fails.

What I find really strange is that sipster installed with:

$ env CXX=gcc-5 npm install git+https://github.com/vgire/sipster.git

can now do quite a few things before failing to create the log file so it feels like I am not far from having it running.

Also, my pjsip install does work with the python's bindings.

byoungdale commented 8 years ago

Were you able to find a solution for this problem? I am experiencing the same error on CentOS 6.6, but have not been able to resolve it. Even after following the steps you tried on this thread so far.

mscdex commented 8 years ago

@byoungdale Which problem?

byoungdale commented 8 years ago

Sorry @mscdex , the original error that @vgire reported with installing sipster to OSX El Capitan. Except I am getting the exact same error on CentOS 6.

> sipster@0.1.0 install /home/vagrant/node_modules/sipster
> node-gyp rebuild

gyp: Call to 'pkg-config --atleast-version=2.4.5 libpjproject' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1

gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 2.6.32-504.23.4.el6.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/vagrant/node_modules/sipster
gyp ERR! node -v v4.4.3
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Linux 2.6.32-504.23.4.el6.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "sipster"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE

npm ERR! sipster@0.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sipster@0.1.0 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the sipster package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs sipster
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls sipster
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/npm-debug.log
mscdex commented 8 years ago

@byoungdale That's a different error. Do you have pkg-config and pjsip 2.4.5+ installed?

byoungdale commented 8 years ago

@mscdex I did need to update the pkg-config package. But, now I am getting this error now however:

cc1plus: warning: unrecognized command line option "-Wno-maybe-uninitialized"
make: *** [Release/obj.target/sipster/src/binding.o] Error 1
make: Leaving directory `/home/vagrant/node_modules/sipster/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 2.6.32-504.23.4.el6.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/vagrant/node_modules/sipster
gyp ERR! node -v v4.4.3
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Linux 2.6.32-504.23.4.el6.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "sipster"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE

npm ERR! sipster@0.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sipster@0.1.0 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the sipster package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs sipster
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls sipster
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/npm-debug.log

Do you know what this cc1plus: warning: unrecognized command line option "-Wno-maybe-uninitialized" error means? Am I missing a different dependencies?

mscdex commented 8 years ago

@byoungdale Perhaps you have to upgrade your compiler? What gcc/clang version are you using?

byoungdale commented 8 years ago

@mscdex gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC). I'll try updating it.

mscdex commented 8 years ago

@byoungdale You need to upgrade to gcc 4.8 or newer. This is a general requirement inherited from node/node-gyp.

byoungdale commented 8 years ago

@mscdex upgraded to gcc version 4.9.2 20150212 (Red Hat 4.9.2-6) (GCC), but still getting the same error.

mscdex commented 8 years ago

Are you sure the old compiler isn't getting picked up somehow? What does gcc -v show? What does echo $CC/echo $CXX show?

byoungdale commented 8 years ago

Initially gcc - v showed gcc version 4.9.2 20150212 (Red Hat 4.9.2-6) (GCC), but now it is back to showing gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC). Not sure what I did wrong on the install. I will need to revisit this.

mscdex commented 8 years ago

@byoungdale How did you install the newer gcc, via a devtoolset? If that is the case, you will need to do scl enable devtoolset-3 bash or for whatever devtoolset you're using to get a new bash session with the environment variables set up properly. From there you should be able to gcc -v and see 4.9.2 listed. Reinstall sipster from inside that bash session and it should work.

If you've just installed the newer gcc via the normal means (through a repo), it may be that the compiler was installed with a suffix (e.g. gcc49) to allowed it to be used alongside the original compiler. I know RedHat/CentOS does do things like that. In that case, you should be able to do something like CC=gcc49 CXX=g++49 npm install sipster