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

node 6 breaks this #1

Closed
mcarifio opened this issue May 10, 2016 · 3 comments
Closed

node 6 breaks this #1

mcarifio opened this issue May 10, 2016 · 3 comments

Comments

@mcarifio
Copy link

First, ty for a useful module.

Next, for node 6:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial

$ node --version
v6.1.0

$ node

var Av = require('autovivify');
undefined
var used = new Av();
undefined
used.x.y =1
1
used.x
{ y: 1 }
used
{ x: { y: 1 } }

Object.prototype.toString.call(used) // no toString() method?, how do I find the actual type of 'used'?
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Aborted

@allenluce
Copy link
Owner

Looks like this is sensitive to a change in v8 between 4.8.271.17 and 4.9.385.18. I was able to confirm that this breaks with node's commit 079973b96 (and works on 893835539). Updating nan/node-gyp didn't magically fix it, so I guess it's going to take a little more digging.

allenluce pushed a commit that referenced this issue May 12, 2016
This is to address #1

Some change occurred between the node repo's commits 893835539 and
079973b96 (corresponding to v8 versions 4.8.271.17 and 4.9.385.18) that
makes toString() cause node to die with a `basic_string::_S_construct
NULL not valid` error message.

It seems that the new node.js calls the property getter with an invalid
property address to query (after first calling for a toString property
on instance and object). This causes the fault.

It's not 100% clear what's happening, but adding a toString() method
gets some functionality working. Using Object.prototype.toString.call()
on the object still bombs.
allenluce pushed a commit that referenced this issue May 12, 2016
This is to address #1

Some change occurred between the node repo's commits 893835539 and
079973b96 (corresponding to v8 versions 4.8.271.17 and 4.9.385.18) that
makes toString() cause node to die with a `basic_string::_S_construct
NULL not valid` error message.

It seems that the new node.js calls the property getter with an invalid
property address to query (after first calling for a toString property
on instance and object). This causes the fault.

It's not 100% clear what's happening, but adding a toString() method
gets some functionality working. Using Object.prototype.toString.call()
on the object still bombs.
@allenluce
Copy link
Owner

allenluce commented May 12, 2016

I'm still not totally sure what is going on but did add a toString() method. In previous versions, v8 compensates for the lack of one on the embedded object but that seems to have broken with the newer versions.

1.0.5 is now up. Object.prototype.toString() still bombs when applied to an autovivified object but the .toString() method on the object itself no longer does. Let me know if that fits your use.

@allenluce
Copy link
Owner

OK, figured it out. The 1.0.6 version should no longer bomb on Object.prototype.toString.call(). Type returns as '[object AutoVivify]'. If there's a call to have it masquerade as a '[object Object]' I can probably build that in.

allenluce added a commit that referenced this issue Oct 14, 2016
This is to address #1

Some change occurred between the node repo's commits 893835539 and
079973b96 (corresponding to v8 versions 4.8.271.17 and 4.9.385.18) that
makes toString() cause node to die with a `basic_string::_S_construct
NULL not valid` error message.

It seems that the new node.js calls the property getter with an invalid
property address to query (after first calling for a toString property
on instance and object). This causes the fault.

It's not 100% clear what's happening, but adding a toString() method
gets some functionality working. Using Object.prototype.toString.call()
on the object still bombs.
allenluce added a commit that referenced this issue Oct 14, 2016
So when Node 6+ wants to do an Object.prototype.toString call, it first
sends a query for a property (the GetToStringTag property, in
particular). Autovivify didn't know how to deal with this query, so
would bomb.

This has the property getter just return if it's asked for a
symbol. This lets v8 fall through to its own stringify routines, so an
appropriate value is emitted ("[object AutoVivify]").

This also removes the explicit toString method as the existing fall-back
one seems to work just fine.

This fixes #1
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