intel / iotivity-node

Node.js bindings for IoTivity
https://www.iotivity.org/
42 stars 44 forks source link

high level client crash #98

Closed sanbeam closed 7 years ago

sanbeam commented 7 years ago

Client crashes with the following issue.

{"devAddr":{"adapter":2,"flags":0,"ifindex":0,"port":0,"addr":""},"addr":{"adapter":2,"flags":0,"ifindex":0,"port":0,"addr":""},"connType":131072,"identity":[],"result":255,"sequenceNumber":0,"resourceUri":"/oic/res","rcvdVendorSpecificHeaderOptions":[]} /home/sanjeev/source/jlr/node_modules/iotivity-node/lib/csdk.js:39 throw theError; ^

Error: findResources: Unexpected response

sanbeam commented 7 years ago

Bump. Someone please look into this.

gabrielschulhof commented 7 years ago

It looks like some server on the network is issuing OC_STACK_ERROR in response to a resource discovery. I would say check the server, and attach an error handler to the client so it doesn't end up throwing a fatal exception.

rzr commented 7 years ago

Discovery worked for me on 1.2 using high level client / server... but then hang, I will have to investigate too

sanbeam commented 7 years ago

Just curious. Is security enabled by default ?

sanbeam commented 7 years ago

Just curious. Is security enabled by default ? If yes, how do i get insecure version at npm install ?

rzr commented 7 years ago

upstream and meta-oic have SECURED=0 by default on 1.2.1 and under, I aligned to that

gabrielschulhof commented 7 years ago

If you want to build with SECURED=0 you have to build iotivity externally, then export OCTBSTACK_CFLAGS and OCTBSTACK_LIBS.

sanbeam commented 7 years ago

Thanks for confirming. I think these two were the issues. I ll test and update soon.

sanbeam commented 7 years ago

Did the following steps.

  1. package.json : "iotivity-node": "git+https://github.com/otcshare/iotivity-node#maintenance"

  2. git clone https://git.iotivity.org/iotivity pushd iotivity git fetch --all --tags --prune git checkout tags/1.2.0 -b 1.2.0 git clone https://github.com/01org/tinycbor.git extlibs/tinycbor/tinycbor pushd extlibs/tinycbor/tinycbor/ git checkout tags/v0.3.2 popd echo "Now in " pwd scons resource SECURED=0 TARGET_TRANSPORT=IP echo "Build Completed" export IOTIVITY_DIR=pwd export OCTBSTACK_CFLAGS="-I$IOTIVITY_DIR/resource/csdk/stack/include \ -I$IOTIVITY_DIR/resource/csdk/connectivity/inc/ \ -I$IOTIVITY_DIR/resource/csdk/connectivity/api \ -I$IOTIVITY_DIR/resource/include \ -I$IOTIVITY_DIR/resource/oc_logger/include/\ -I$IOTIVITY_DIR/resource/c_common/oic_string/include/\ -I$IOTIVITY_DIR/resource/c_common/oic_malloc/include/\ -I$IOTIVITY_DIR/resource/c_common/\ -I$IOTIVITY_DIR/resource/c_common/oic_time/include/\ -I$IOTIVITY_DIR/resource/c_common/\ -I$IOTIVITY_DIR/resource/c_common/ocrandom/include/\ -I$IOTIVITY_DIR/extlibs/tinycbor/tinycbor/src\ -I$IOTIVITY_DIR/resource/csdk/stack/include/" export OCTBSTACK_LIBS="-L$IOTIVITY_DIR/out/linux/x86_64/release -loc -loctbstack -lconnectivity_abstraction -loc_logger" echo $IOTIVITY_DIR echo $OCTBSTACK_CFLAGS echo $OCTBSTACK_LIBS popd echo "Now in pwd " npm install

  3. Step 2 went fine.

  4. node node_modules/iotivity-node/js/high-level-client-example.js Acquiring OCF device Issuing discovery request Segmentation fault (core dumped)

  5. GDB Trace

http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from node...done. (gdb) r ./node_modules/iotivity-node/js/high-level-client-example.js Starting program: /usr/bin/node ./node_modules/iotivity-node/js/high-level-client-example.js [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff7ff5700 (LWP 23819)] [New Thread 0x7ffff6b43700 (LWP 23820)] [New Thread 0x7ffff6342700 (LWP 23821)] [New Thread 0x7ffff5b41700 (LWP 23822)] [New Thread 0x7ffff5340700 (LWP 23823)] Acquiring OCF device [New Thread 0x7fffe7fff700 (LWP 23824)] [New Thread 0x7fffe77fe700 (LWP 23825)] [New Thread 0x7fffe6ffd700 (LWP 23826)] [New Thread 0x7fffe67fc700 (LWP 23827)] Issuing discovery request

Thread 1 "node" received signal SIGSEGV, Segmentation fault. strlen () at ../sysdeps/x86_64/strlen.S:106 106 ../sysdeps/x86_64/strlen.S: No such file or directory. (gdb) bt

0 strlen () at ../sysdeps/x86_64/strlen.S:106

1 0x0000000000a0250e in v8::String::NewFromUtf8(v8::Isolate, char const, v8::NewStringType, int) ()

2 0x00007ffff4937ae9 in js_OCPayload(OCPayload*) () from /home/sanjeev/source/testserver/node_modules/iotivity-node/build/Release/iotivity.node

3 0x00007ffff492ebd9 in js_OCClientResponse(OCClientResponse*) () from /home/sanjeev/source/testserver/node_modules/iotivity-node/build/Release/iotivity.node

4 0x00007ffff4923bb2 in defaultOCClientResponseHandler(void, void, OCClientResponse*) () from /home/sanjeev/source/testserver/node_modules/iotivity-node/build/Release/iotivity.node

5 0x00007ffff46df9dd in OCHandleResponse () from ./iotivity/out/linux/x86_64/release/liboctbstack.so

6 0x00007ffff42bcb3f in CAHandleRequestResponseCallbacks () from ./iotivity/out/linux/x86_64/release/libconnectivity_abstraction.so

7 0x00007ffff42bbc23 in CAHandleRequestResponse () from ./iotivity/out/linux/x86_64/release/libconnectivity_abstraction.so

8 0x00007ffff46e0a3d in OCProcess () from ./iotivity/out/linux/x86_64/release/liboctbstack.so

9 0x00007ffff492d15f in bind_OCProcess(Nan::FunctionCallbackInfo const&) () from /home/sanjeev/source/testserver/node_modules/iotivity-node/build/Release/iotivity.node

10 0x00007ffff491cad5 in Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfo const&) () from /home/sanjeev/source/testserver/node_modules/iotivity-node/build/Release/iotivity.node

11 0x0000000000a1afa9 in v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo const&)) ()

12 0x0000000000a92f4d in v8::internal::MaybeHandle v8::internal::(anonymous namespace)::HandleApiCallHelper(v8::internal::Isolate*, v8::internal::Handle, v8::internal::Handle, v8::internal::Handle, v8::internal::Handle, v8::internal::BuiltinArguments) [clone .constprop.44] ()

13 0x0000000000a93d7c in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object*, v8::internal::Isolate) ()

14 0x0000192731b063a7 in ?? ()

15 0x0000000002107dc0 in ?? ()

16 0x0000192731b062e1 in ?? ()

17 0x00007fffffffc910 in ?? ()

18 0x0000000300000000 in ?? ()

19 0x00007fffffffc988 in ?? ()

20 0x0000192731cde2bb in ?? ()

21 0x00003cf868e04311 in ?? ()

22 0x00002c7a0d80a859 in ?? ()

23 0x0000000400000000 in ?? ()

24 0x0000083db103b379 in ?? ()

25 0x00002c7a0d80a859 in ?? ()

26 0x0000083db1009639 in ?? ()

27 0x00003cf868e04311 in ?? ()

28 0x0000083db10e9669 in ?? ()

29 0x0000083db1009639 in ?? ()

30 0x00007fffffffc9d0 in ?? ()

31 0x0000192731cdde01 in ?? ()

32 0x0000083db10e9881 in ?? ()

33 0x00003cf868ea7d69 in ?? ()

34 0x0000083db10e9669 in ?? ()

35 0x00003cf868e04311 in ?? ()

36 0x00003cf868e04311 in ?? ()

37 0x00002c7a0d8b3451 in ?? ()

38 0x00002c7a0d866a81 in ?? ()

39 0x00007fffffffca20 in ?? ()

40 0x0000192731cddb0b in ?? ()

41 0x0000083db10e9881 in ?? ()

42 0x00003cf868e04311 in ?? ()

43 0x00002c7a0d8b3451 in ?? ()

44 0x00002c7a0d866a81 in ?? ()

45 0x00003cf868e043b1 in ?? ()

46 0x00003cf868e04311 in ?? ()

47 0x00002c7a0d8b3331 in ?? ()

48 0x00002c7a0d866a81 in ?? ()

49 0x00007fffffffca98 in ?? ()

50 0x0000192731cdd42b in ?? ()

51 0x0000083db10ea0c9 in ?? ()

52 0x0000083db10e9881 in ?? ()

53 0x00003cf868e04311 in ?? ()

54 0x00002c7a0d8b3331 in ?? ()

55 0x00003cf868e04311 in ?? ()

56 0x00003cf868e04311 in ?? ()

---Type to continue, or q to quit---Quit (gdb) Quit

sanbeam commented 7 years ago

@gabrielschulhof, please help me set this up.

sanbeam commented 7 years ago

Forgot to add ROUTING_EP. My bad.