Skip to content

i2cReadByte() Segmentation Fault #56

Open

Description

@mzwtjp

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) {
 
 }

Activity

  1. rzr commented on Jul 3, 2019

    @rzr

    May this patch be forwarded upstream ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions