kelly / node-i2c

Node.js native bindings for i2c-dev. Plays well with Raspberry Pi and Beaglebone.
Other
216 stars 91 forks source link

Segfault #47

Closed risacher closed 9 years ago

risacher commented 9 years ago

I repeatably get a segfault that I think is in i2c, but it takes a few hours for it to happen. During that time, the process size grows slowly, so maybe it's a memory leak issue?

I am using node 0.10.33 and adafruit-i2c-lcd on a raspberry pi B; with i2c module pulled from latest github. The test program scrolls text across the lcd display, changing the text on a 100ms interval.

Unfortunately when the segfault happens, it seems to corrupt the stack, so I haven't been able to get a good backtrace in gdb or core file.

risacher commented 9 years ago

Here's the test program that causes the crash: http://risacher.org/ref/test2-buttons.js

risacher commented 9 years ago

if anyone has tips on how to debug this, I'd much appreciate.

kelly commented 9 years ago

You could try upgrading to the latest version of i2c. It looks like that project depends on 0.1.4, but you shouldn't have any problems upgrading it to 0.1.6.

risacher commented 9 years ago

well, what I actually put in the adafruit-i2c-lcd/package.json dependencies is this:

"i2c": "git://github.com/kelly/node-i2c.git"

But it doesn't help

risacher commented 9 years ago

[edited]The segfault always happens inside ReadBlock().

risacher commented 9 years ago

At src/i2c.cc:133 The SEGV happens on this line: Local actualBuffer = bufferConstructor->NewInstance(3, constructorArgs);

arskb4ga commented 9 years ago

Did this SEGV ever get resolved?

risacher commented 9 years ago

I don't think so. I haven't tested it lately - that project went on indefinite hold. I'll try it tonight.

risacher commented 9 years ago

I upgraded to node 0.12.6; ran npm update, which pulled in i2c v0.2.1. I then ran my test program and let it run all night - no segfault. I forgot to check for process growth. I'm running the test again, but I think the problem is resolved. If it hasn't crashed by tonight, I'll close the issue.

arskb4ga commented 9 years ago

Thanks for your work testing this! I am running Node 10.38 on a PI-2, I have not been able to get the PI to load version Node 12. What platform are you running? I tested with another i2c program and it ran OK, but I used readByte and not readyBytes (block), I would assume it would fail if I used the block mode also until upgrade node, based on my reading.

risacher commented 9 years ago

My pi's (I think I have 3) are RPi 1 Model B. I installed node 0.12.6 via instructions at http://weworkweplay.com/play/raspberry-pi-nodejs/ - basically a installed a package built by heroku.

arskb4ga commented 9 years ago

Thanks, I will take a look at this, it will save me a lot of time if it works.

arskb4ga commented 9 years ago

I have been testing for a while with node 0.12.6 and it seems to be working fine. I don't notice the memory leak that were there with 0.10.38. Strange it was intermittent when it came to how long the process ran before the segfault.

risacher commented 9 years ago

No crash; no leak. Closing.