Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Segfault: 11 using node platform #3678

Closed
buchanae opened this issue Jan 24, 2016 · 5 comments
Closed

Segfault: 11 using node platform #3678

buchanae opened this issue Jan 24, 2016 · 5 comments
Assignees
Labels
bug documentation Node.js node-mapbox-gl-native
Milestone

Comments

@buchanae
Copy link

On Mac OSX 10.11.2
Node v5.0.0 (also tried v4.2.6)

This is the script: https://gist.github.com/abuchanan/5f3c3737469661314975

Error:

node js/init.js
PID 62870 received SIGSEGV for address: 0x880
0   segfault-handler.node               0x00000001049f1ecb _ZL16segfault_handleriP9__siginfoPv + 283
1   libsystem_platform.dylib            0x00007fff9b963eaa _sigtramp + 26
2   ???                                 0x0000000500000100 0x0 + 21474836736
3   mapbox-gl-native.node               0x0000000103a0af75 _ZN9node_mbgl15NodeLogObserverD0Ev + 53
4   libsystem_c.dylib                   0x00007fff97e6246b __cxa_finalize_ranges + 345
5   libsystem_c.dylib                   0x00007fff97e6276f exit + 55
6   node                                0x000000010000263b start + 59
7   ???                                 0x0000000000000002 0x0 + 2

Directory:

tree -I node_modules .
.
├── crash.log
├── fixtures
│   └── tiles
│       └── 0-0-0.vector.pbf
├── image.png
├── js
│   └── init.js
└── package.json

I've tried both plain npm install mapbox-gl-native and downloading/building the code. npm test passes, but when I pull the test code (from "renders image") out, it does segfault also, that's just not reflected by the test results.

It does write image.png but it's not an actual PNG and can't be opened.

I'm stumped.

@1ec5 1ec5 added the Node.js node-mapbox-gl-native label Jan 24, 2016
@mikemorris mikemorris self-assigned this Jan 25, 2016
@mikemorris
Copy link
Contributor

I think this was an issue introduced in v3.0.0, I'm working on tracking this down.

@jfirebaugh
Copy link
Contributor

There's a bug in the node README that presumably got propagated to the script.

map.render({}, function(err, image) {
    if (err) throw err;
    fs.writeFileSync('image.png', image);
});

This doesn't write a valid PNG file, because map.render produces a raw RGBA buffer. You need to encode it to the desired image format yourself.

@mikemorris
Copy link
Contributor

Oops, yea, thought this was a different issue. map.render used to return a PNG, looks like the examples were never updated to reflect that it returns raw RGBA now.

@buchanae
Copy link
Author

buchanae commented Feb 9, 2016

Thanks guys. I am able to write an image now (although it took me awhile to find an image library that worked. I ended up with picha)

Still segfaults though.

@mikemorris mikemorris added the bug label Apr 7, 2016
@mikemorris
Copy link
Contributor

Sorry for the slow response, finally got some time to look into this and I was able to reproduce the segfault you're seeing - it looks like we're not cleaning up properly when the script exits and trying to improperly Reset() a v8::Persistent in the NodeLog destructor.

* thread #1: tid = 0x393cb, 0x00000001002e6bed node`v8::internal::GlobalHandles::Node::Release() + 173, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x880)
  * frame #0: 0x00000001002e6bed node`v8::internal::GlobalHandles::Node::Release() + 173
    frame #1: 0x0000000104002515 mapbox-gl-native.node`node_mbgl::NodeLogObserver::~NodeLogObserver() [inlined] v8::PersistentBase<v8::Object>::Reset() + 53 at v8.h:7234
    frame #2: 0x0000000104002507 mapbox-gl-native.node`node_mbgl::NodeLogObserver::~NodeLogObserver() [inlined] Nan::Persistent<v8::Object, v8::NonCopyablePersistentTraits<v8::Object> >::Reset() at nan_persistent_12_inl.h:24
    frame #3: 0x0000000104002507 mapbox-gl-native.node`node_mbgl::NodeLogObserver::~NodeLogObserver() [inlined] node_mbgl::NodeLogObserver::~NodeLogObserver(this=<unavailable>) + 30 at node_log.cpp:55
    frame #4: 0x00000001040024e9 mapbox-gl-native.node`node_mbgl::NodeLogObserver::~NodeLogObserver() [inlined] node_mbgl::NodeLogObserver::~NodeLogObserver(this=<unavailable>) at node_log.cpp:53
    frame #5: 0x00000001040024e9 mapbox-gl-native.node`node_mbgl::NodeLogObserver::~NodeLogObserver(this=0x0000000101712eb0) + 9 at node_log.cpp:53
    frame #6: 0x00007fff90cee46b libsystem_c.dylib`__cxa_finalize_ranges + 345
    frame #7: 0x00007fff90cee76f libsystem_c.dylib`exit + 55
    frame #8: 0x000000010000103b node`start + 59

@mikemorris mikemorris added this to the node-v3.0.3 milestone Apr 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug documentation Node.js node-mapbox-gl-native
Projects
None yet
Development

No branches or pull requests

4 participants