eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.37k stars 613 forks source link

mraa.Gpio causes core dump in SetAlignedPointerInInternalField #619

Closed maihde closed 7 years ago

maihde commented 7 years ago

While attempting to follow the IoT Joule getting started guide:

`

var mraa = require('mraa') undefined var led = mraa.Gpio(101) FATAL ERROR: v8::Object::SetAlignedPointerInInternalField() Internal field out of bounds Aborted (core dumped) `

This is with the following MRAA version

`

mraa-gpio version

Version v1.5.1-11-gc1017bb on Intel GT Tuchuck `

The relevant portion of the backtrace is:

`

5 0x00000000005b9c91 in v8::Object::SetAlignedPointerInInternalField(int, void*) ()

6 0x00007ffff458729b in SWIGV8_SetPrivateData(v8::Local, void, swig_type_info, int) () from /usr/lib/node_modules/mraa/mraa.node

7 0x00007ffff459f7b2 in _wrap_new_Gpio__SWIG_2(v8::FunctionCallbackInfo const&, V8ErrorHandler&) () from /usr/lib/node_modules/mraa/mraa.node

8 0x00007ffff459fb99 in _wrap_new_Gpio(v8::FunctionCallbackInfo const&) () from /usr/lib/node_modules/mraa/mraa.node

9 0x00000000005d760a in v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo const&)) ()

`

alext-mkrs commented 7 years ago

Mraa version looks like if you've compiled it on your own. Have you?

Have you tried any other pins, e.g. 102? i don't have Joule to check this out, but Gpio under Node functionality is very basic and very well tested, so it looks a bit strange at the first glance.

maihde commented 7 years ago

Per the Joule first-time setup guide, I followed the steps as described here:

https://software.intel.com/en-us/updating-libraries-for-joule

And then attempted:

https://software.intel.com/en-us/node/672541

I've also tried other GPIO pins and had the same issue.

On Tue, Dec 13, 2016 at 2:06 PM, Alex T notifications@github.com wrote:

Mraa version looks like if you've compiled it on your own. Have you?

Have you tried any other pins, e.g. 102? i don't have Joule to check this out, but Gpio under Node functionality is very basic and very well tested, so it looks a bit strange at the first glance.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/intel-iot-devkit/mraa/issues/619#issuecomment-266830790, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOCIiYJMHTEftBrokNSJEaoo_0ZjRL8ks5rHuymgaJpZM4LKDKa .

claytongulick commented 7 years ago

I'm experiencing the same issue on the Edison. I updated mraa, installed updated agent, etc... still no luck. Also, SSH'd in to the board and tried a npm rebuild, but that didn't help either. I just get: ERROR: FATAL ERROR: v8::Object::SetAlignedPointerInInternalField() Internal field out of bounds on the first call to Gpio in node.

alext-mkrs commented 7 years ago

@claytongulick, could you please share the source of the program you are running when you get that error, as well as describe how do you run/upload it (e.g. XDK, manually from the SSH console, etc)?

alext-mkrs commented 7 years ago

Ok, never mind, I can see that as well on Edison, nothing fancy to reproduce, so looks like something broke this basic functionality, but in JS only, Python is fine.

root@edison1:~/mraa-619# node
> var m = require('mraa')
undefined
> m.setLogLevel(7)
0
> var g = m.Gpio(3)
FATAL ERROR: v8::Object::SetAlignedPointerInInternalField() Internal field out of bounds
Aborted

Nothing overly interesting in the syslog:

Dec 18 20:03:17 edison1 libmraa[6917]: libmraa version v1.5.1-11-gc1017bb initialised by user 'root' with EUID 0
Dec 18 20:03:17 edison1 libmraa[6917]: edison: Arduino board detected
Dec 18 20:03:17 edison1 libmraa[6917]: libmraa initialised for platform 'Intel Edison' of type 2
Dec 18 20:03:28 edison1 libmraa[6917]: Loglevel 7 is set
Dec 18 20:03:47 edison1 libmraa[6917]: gpio219: owner: Set owner to 0
alext-mkrs commented 7 years ago

Well, that's actually just a typo in the instruction. There's new missing in the var led = mraa.Gpio(101) line (and in my test above as well as I tried the steps literally). So nothing is broken in mraa and if you run the bundled example, e.g. examples/javascript/GPIO_DigitalWrite.js, changing the pin number inside to the one you are interested in, you'll see it works fine.

I.e. it should be like this (using interactive session and pin 3 on Edison):

root@edison1:~/mraa/build# node
> var m = require('mraa')
undefined
> var g = new m.Gpio(3)
undefined
> g.write(1) // the LED lights up here
0
> g.write(0) // the LED switches off
0
> // Ctrl+C here
root@edison1:~/mraa/build#

EDIT: the irony is that in the GitHub-stored code they refer to in the article, the new keyword actually exists, so it's only the article, which has an incorrect listing. @maihde, I've reported this in the Joule support forum, so hopefully they fix the article.

claytongulick commented 7 years ago

@alext-mkrs thanks, I'll try that! BTW - are you all accepting pull requests for this? Using new in js is sometimes considered a bit of an antipattern in an API, I could tweak the Gpio function to detect how it's being called and work either way, if you'd like.

maihde commented 7 years ago

Thanks Alan. Is there a mechanism to get the documentation authors to update their docs?

Regards, Michael

On Sunday, December 18, 2016, Alex T notifications@github.com wrote:

Closed #619 https://github.com/intel-iot-devkit/mraa/issues/619.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/intel-iot-devkit/mraa/issues/619#event-897943343, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOCIrNSd8umPO4u8wXjNUC7udr07AR0ks5rJZyAgaJpZM4LKDKa .

arfoll commented 7 years ago

@claytongulick sure that'd be awesome. We've always had this 'new' requirement in mraa's JS API, I know it's considered an antipattern by some, i'd argue JS just isn't a very nice & clean language anyways so arguing about antipatterns is pretty pointless!

alext-mkrs commented 7 years ago

@maihde, I guess that was question for me, as you're replying to my comnent? ;)

I have no idea, most probably there's some way for authors to correct their texts and looks like Intel support folks have already addresed that as necessary, they reported back in the thread I had started.