Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2cReadByte() Segmentation Fault #56

Open
mzwtjp opened this issue Nov 8, 2018 · 1 comment
Open

i2cReadByte() Segmentation Fault #56

mzwtjp opened this issue Nov 8, 2018 · 1 comment

Comments

@mzwtjp
Copy link

mzwtjp commented Nov 8, 2018

I am using i2c module from bonescript, on PocketBeagle.
I am seeing sometimes readByte(i2cReadByte in BoneScript) causes Segmentation Fault in its native code.

I printf debugged and by following change the problem seems to be gone.
The issue happens when you have read error (-1 is returned from i2c_smbus_read_byte()).

Note sure this is bonescript issue or i2c module issue.

--- i2c.cc.orig	2018-11-05 13:31:01.892701107 +0000
+++ i2c.cc.new	2018-11-08 08:41:40.050789179 +0000
@@ -127,7 +127,7 @@ void Read(const Nan::FunctionCallbackInf
 void ReadByte(const Nan::FunctionCallbackInfo<v8::Value>& info) {
   Nan::HandleScope scope;
   
-  Local<Value> data; 
+  Local<Value> data = Nan::New<Value>(Nan::Null());
   Local<Value> err = Nan::New<Value>(Nan::Null());
 
   int32_t res = i2c_smbus_read_byte(fd);
@@ -292,4 +292,4 @@ void Init(Handle<Object> exports) {
 
 }
@rzr
Copy link

rzr commented Jul 3, 2019

May this patch be forwarded upstream ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants