You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IntArray is being set to null when passed as argument through ffi to c functionr.
The IntArray is being initialized just fine, in node, but when passed to my c functions, it is setting the pointer to NULL. I'm using c++14 and suspect this may have something to do with the problem. Alas, it seems inconsistent, it is working in some cases and not in others -- could be memory/pointer issues in my code, but valgrind is not indicating anything in this or any other test. I'm using GCC 5.2 and node 7.5
in node
let IntArray = ArrayType(ref.types.int);
let neuronsPerLayer = new IntArray(3)
let data =spike.completeNetwork(neuronsPerLayer, 3)
in .h file
NetworkDataArray* completeNetwork(int* neuronsPerLayer, int numLayers);
in .cpp file
NetworkDataArray* completeNetwork(int* neuronsPerLayer, int numLayers) {
//neuronsPerLayer is 0, so it crashes as soon as I try an access it
std::vector<int> n(neuronsPerLayer, neuronsPerLayer + numLayers);
...
}
In the ffi file
let libSpike = ffi.Library('source/libspike.so', {
'completeNetwork' : [NetworkDataRef,[IntArray, 'int']]})
backtrace from gcc
#0 0x00007ffff4504829 in completeNetwork (neuronsPerLayer=0x0, numLayers=3) at /home/john/SPIKE/source/spike_wrap.cpp:44 #1 0x00007ffff472ebc2 in ffi_call_unix64 () from /home/john/SPIKE/node_modules/ffi/build/Release/ffi_bindings.node #2 0x00007ffff472d71e in ffi_call () from /home/john/SPIKE/node_modules/ffi/build/Release/ffi_bindings.node #3 0x00007ffff4724c94 in FFI::FFICall(Nan::FunctionCallbackInfov8::Value const&) () from /home/john/SPIKE/node_modules/ffi/build/Release/ffi_bindings.node #4 0x00007ffff4724686 in Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfov8::Value const&) () from /home/john/SPIKE/node_modules/ffi/build/Release/ffi_bindings.node #5 0x0000000000a980d5 in v8::internal::FunctionCallbackArguments::Call(void ()(v8::FunctionCallbackInfov8::Value const&)) () #6 0x0000000000b0afec in v8::internal::MaybeHandlev8::internal::Object v8::internal::(anonymous namespace)::HandleApiCallHelper(v8::internal::Isolate, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8::internal::FunctionTemplateInfo, v8::internal::Handlev8::internal::Object, v8::internal::BuiltinArguments) () #7 0x0000000000b0b565 in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()
Anyway, not totally sure this is IntArray problem or a problem in my own code. However, I'm not having any issues running in pure c/c++.
The text was updated successfully, but these errors were encountered:
IntArray is being set to null when passed as argument through ffi to c functionr.
The IntArray is being initialized just fine, in node, but when passed to my c functions, it is setting the pointer to NULL. I'm using c++14 and suspect this may have something to do with the problem. Alas, it seems inconsistent, it is working in some cases and not in others -- could be memory/pointer issues in my code, but valgrind is not indicating anything in this or any other test. I'm using GCC 5.2 and node 7.5
in node
in .h file
in .cpp file
In the ffi file
backtrace from gcc
#0 0x00007ffff4504829 in completeNetwork (neuronsPerLayer=0x0, numLayers=3) at /home/john/SPIKE/source/spike_wrap.cpp:44
#1 0x00007ffff472ebc2 in ffi_call_unix64 () from /home/john/SPIKE/node_modules/ffi/build/Release/ffi_bindings.node
#2 0x00007ffff472d71e in ffi_call () from /home/john/SPIKE/node_modules/ffi/build/Release/ffi_bindings.node
#3 0x00007ffff4724c94 in FFI::FFICall(Nan::FunctionCallbackInfov8::Value const&) () from /home/john/SPIKE/node_modules/ffi/build/Release/ffi_bindings.node
#4 0x00007ffff4724686 in Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfov8::Value const&) () from /home/john/SPIKE/node_modules/ffi/build/Release/ffi_bindings.node
#5 0x0000000000a980d5 in v8::internal::FunctionCallbackArguments::Call(void ()(v8::FunctionCallbackInfov8::Value const&)) ()
#6 0x0000000000b0afec in v8::internal::MaybeHandlev8::internal::Object v8::internal::(anonymous namespace)::HandleApiCallHelper(v8::internal::Isolate, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8::internal::FunctionTemplateInfo, v8::internal::Handlev8::internal::Object, v8::internal::BuiltinArguments) ()
#7 0x0000000000b0b565 in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()
Anyway, not totally sure this is IntArray problem or a problem in my own code. However, I'm not having any issues running in pure c/c++.
The text was updated successfully, but these errors were encountered: