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

v8::ObjectTemplate::Set() with non-primitive values is deprecated #119

Closed
19h opened this issue Sep 10, 2016 · 4 comments · Fixed by #150
Closed

v8::ObjectTemplate::Set() with non-primitive values is deprecated #119

19h opened this issue Sep 10, 2016 · 4 comments · Fixed by #150
Assignees

Comments

@19h
Copy link

19h commented Sep 10, 2016

v8::ObjectTemplate::Set() with non-primitive values is deprecated is thrown when setting a buffer as a key of an object.

(node) v8::ObjectTemplate::Set() with non-primitive values is deprecated
(node) and will stop working in the next major release.

==== JS stack trace =========================================

Security context: 0x39bedbdcfb51 <JS Object>#0#
    1: .node [module.js:583] [pc=0x21a9083b0084] (this=0xca7697d3061 <an Object with map 0x917767272a9>#1#,module=0x920c02212e9 <a Module with map 0x9177672bef9>#2#,filename=0x920c021f5e1 <String[42]: /path/to/neonmodule/native/index.node>)
    2: load [module.js:473] [pc=0x21a9083a9ff2] (this=0x920c02212e9 <a Module with map 0x9177672bef9>#2#,filename=0x920c021f5e1 <String[42]: /path/to/neonmodule/native/index.node>)
    3: tryModuleLoad(aka tryModuleLoad) [module.js:432] [pc=0x21a9083a9b1d] (this=0x39bedbd04381 <undefined>,module=0x920c02212e9 <a Module with map 0x9177672bef9>#2#,filename=0x920c021f5e1 <String[42]: /path/to/neonmodule/native/index.node>)
    4: _load [module.js:424] [pc=0x21a9083a30c2] (this=0xca7697d2b69 <JS Function Module (SharedFunctionInfo 0x27c340e89e39)>#3#,request=0x27c340ecfad1 <String[9]: ../native>,parent=0x920c021b3d1 <a Module with map 0x9177672bef9>#4#,isMain=0x39bedbd04271 <false>)
    5: require [module.js:483] [pc=0x21a9083a2af3] (this=0x920c021b3d1 <a Module with map 0x9177672bef9>#4#,path=0x27c340ecfad1 <String[9]: ../native>)
    6: require(aka require) [internal/module.js:20] [pc=0x21a9083a2826] (this=0x39bedbd04381 <undefined>,path=0x27c340ecfad1 <String[9]: ../native>)
    7: /* anonymous */ [/path/to/neonmodule/lib/index.js:4] [pc=0x21a9083ade0e] (this=0x920c021b459 <an Object with map 0x24374f7075e9>#5#,exports=0x920c021b459 <an Object with map 0x24374f7075e9>#5#,require=0x920c021cab1 <JS Function require (SharedFunctionInfo 0x27c340e9bd69)>#6#,module=0x920c021b3d1 <a Module with map 0x9177672bef9>#4#,__filename=0x920c02191f9 <String[37]: /path/to/neonmodule/lib/index.js>,__dirname=0x920c021ca49 <String[28]: /path/to/neonmodule/lib>)
    8: _compile [module.js:556] [pc=0x21a9083adab0] (this=0x920c021b3d1 <a Module with map 0x9177672bef9>#4#,content=0x920c021c3d9 <String[306]\: 'use strict';\n\nconst assert = require('assert');\nconst arx = require('../native');\n\nclass Crypto {\n\x09constructor(arx) {\n\x09\x09assert(arx, 'You must pass an arx instance!');\n\n\x09\x09this.arx = arx;\n\x09}\n\n\x09keypair () {\n\x09\x09return this.arx.keypair();\n\x09}\n}\n\nmodule.exports = new Crypto(arx);\nmodule.exports.Crypto = Crypto;\n>,filename=0x920c02191f9 <String[37]: /path/to/neonmodule/lib/index.js>)
    9: .js [module.js:565] [pc=0x21a9083aad0b] (this=0xca7697d3061 <an Object with map 0x917767272a9>#1#,module=0x920c021b3d1 <a Module with map 0x9177672bef9>#4#,filename=0x920c02191f9 <String[37]: /path/to/neonmodule/lib/index.js>)
   10: load [module.js:473] [pc=0x21a9083a9ff2] (this=0x920c021b3d1 <a Module with map 0x9177672bef9>#4#,filename=0x920c02191f9 <String[37]: /path/to/neonmodule/lib/index.js>)
   11: tryModuleLoad(aka tryModuleLoad) [module.js:432] [pc=0x21a9083a9b1d] (this=0x39bedbd04381 <undefined>,module=0x920c021b3d1 <a Module with map 0x9177672bef9>#4#,filename=0x920c02191f9 <String[37]: /path/to/neonmodule/lib/index.js>)
   12: _load [module.js:424] [pc=0x21a9083a30c2] (this=0xca7697d2b69 <JS Function Module (SharedFunctionInfo 0x27c340e89e39)>#3#,request=0x27c340ec7741 <String[5]: ./lib>,parent=0xca7697e5f09 <a Module with map 0x9177672bef9>#7#,isMain=0x39bedbd04271 <false>)
   13: require [module.js:483] [pc=0x21a9083a2af3] (this=0xca7697e5f09 <a Module with map 0x9177672bef9>#7#,path=0x27c340ec7741 <String[5]: ./lib>)
   14: require(aka require) [internal/module.js:20] [pc=0x21a9083a2826] (this=0x39bedbd04381 <undefined>,path=0x27c340ec7741 <String[5]: ./lib>)
   15: /* anonymous */ [repl:1] [pc=0x21a9083a03e6] (this=0x39bedbde6ee9 <JS Global Object>#8#)
   19: /* anonymous */(aka /* anonymous */) [vm.js:22] [pc=0x21a9083a2688] (this=0x39bedbd04381 <undefined>)
   20: sigintHandlersWrap(aka sigintHandlersWrap) [vm.js:96] [pc=0x21a9083a17c8] (this=0x39bedbd04381 <undefined>,fn=0x920c0216579 <JS Function sigintHandlersWrap (SharedFunctionInfo 0x27c340e67791)>#9#)
   21: runInThisContext [vm.js:21] [pc=0x21a908333227] (this=0x920c0215ef9 <a ContextifyScript with map 0x24374f70fdb1>#10#,options=0x920c0216501 <an Object with map 0x9177672f9c1>#11#)
   22: defaultEval [repl.js:313] [pc=0x21a90839f6d6] (this=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#,code=0x920c0215bf1 <String[21]\: require("./lib").arx\n>,context=0x39bedbde6ee9 <JS Global Object>#8#,file=0x39bedbddd211 <String[4]: repl>,cb=0x920c0215279 <JS Function finish (SharedFunctionInfo 0x27c340ec47e9)>#13#)
   23: bound(aka bound) [domain.js:280] [pc=0x21a90839e0ae] (this=0x39bedbd04381 <undefined>,_this=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#,self=0xca7697e16d9 <a Domain with map 0x9177672aab1>#14#,cb=0xca7697e15f1 <JS Function defaultEval (SharedFunctionInfo 0x27c340e961b9)>#15#,fnargs=0x920c0215c49 <an Arguments with map 0x24374f70ace9>#16#)
   24: eval(aka runBound) [domain.js:293] [pc=0x21a90839deb2] (this=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#)
   25: arguments adaptor frame: 4->0
   26: /* anonymous */ [repl.js:504] [pc=0x21a90839a65f] (this=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#,cmd=0x920c02139e1 <String[20]: require("./lib").arx>)
   27: emitOne(aka emitOne) [events.js:101] [pc=0x21a90838b1f9] (this=0x39bedbd04381 <undefined>,handler=0xca7697fa059 <JS Array[2]>#17#,isFn=0x39bedbd04271 <false>,self=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#,arg1=0x920c02139e1 <String[20]: require("./lib").arx>)
   28: emit [events.js:188] [pc=0x21a908320f00] (this=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#,type=0x39bedbd8beb1 <String[4]: line>)
   29: arguments adaptor frame: 2->1
   30: _onLine [readline.js:232] [pc=0x21a908399bcd] (this=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#,line=0x920c02139e1 <String[20]: require("./lib").arx>)
   31: _line [readline.js:574] [pc=0x21a9083990c3] (this=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#)
   32: _ttyWrite [readline.js:851] [pc=0x21a90836f2a5] (this=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#,s=0x27c340e4b929 <String[1]\: \r>,key=0x920c02147a9 <an Object with map 0x9177672f701>#18#)
   33: _ttyWrite [repl.js:596] [pc=0x21a90838dc6a] (this=0xca7697e1529 <an REPLServer with map 0x9177672e261>#12#,d=0x27c340e4b929 <String[1]\: \r>,key=0x920c02147a9 <an Object with map 0x9177672f701>#18#)
   34: onkeypress [readline.js:119] [pc=0x21a90838daf9] (this=0xca7697e2b79 <a ReadStream with map 0x9177672f499>#19#,s=0x27c340e4b929 <String[1]\: \r>,key=0x920c02147a9 <an Object with map 0x9177672f701>#18#)
   35: emitTwo(aka emitTwo) [events.js:106] [pc=0x21a908321513] (this=0x39bedbd04381 <undefined>,handler=0xca7697ec051 <JS Function onkeypress (SharedFunctionInfo 0x27c340e9df61)>#20#,isFn=0x39bedbd043c1 <true>,self=0xca7697e2b79 <a ReadStream with map 0x9177672f499>#19#,arg1=0x27c340e4b929 <String[1]\: \r>,arg2=0x920c02147a9 <an Object with map 0x9177672f701>#18#)
   36: emit [events.js:191] [pc=0x21a908320f7b] (this=0xca7697e2b79 <a ReadStream with map 0x9177672f499>#19#,type=0x27c340e4b501 <String[8]: keypress>)
   37: arguments adaptor frame: 3->1
   38: emitKeys(aka emitKeys) [internal/readline.js:389] [pc=0x21a90836911f] (this=0x39bedbd04381 <undefined>,stream=0x39bedbd04429 <the hole>)
   39: next [native generator.js:21] [pc=0x21a908369b8a] (this=0xca7697efe49 <JS Generator>#21#,i=0x27c340e4b929 <String[1]\: \r>)
   40: onData [readline.js:955] [pc=0x21a90838b876] (this=0xca7697e2b79 <a ReadStream with map 0x9177672f499>#19#,b=0x920c0214629 <an Uint8Array with map 0x9177672f4f1>#22#)
   41: emitOne(aka emitOne) [events.js:96] [pc=0x21a90838b130] (this=0x39bedbd04381 <undefined>,handler=0xca7697eccd9 <JS Function onData (SharedFunctionInfo 0x27c340e9ef31)>#23#,isFn=0x39bedbd043c1 <true>,self=0xca7697e2b79 <a ReadStream with map 0x9177672f499>#19#,arg1=0x920c0214629 <an Uint8Array with map 0x9177672f4f1>#22#)
   42: emit [events.js:188] [pc=0x21a908320f00] (this=0xca7697e2b79 <a ReadStream with map 0x9177672f499>#19#,type=0x39bedbddd349 <String[4]: data>)
   43: arguments adaptor frame: 2->1
   44: readableAddChunk(aka readableAddChunk) [_stream_readable.js:176] [pc=0x21a90838a98c] (this=0x39bedbd04381 <undefined>,stream=0xca7697e2b79 <a ReadStream with map 0x9177672f499>#19#,state=0xca7697e3451 <a ReadableState with map 0x91776724181>#24#,chunk=0x920c0214629 <an Uint8Array with map 0x9177672f4f1>#22#,encoding=0x39bedbd04381 <undefined>,addToFront=0x39bedbd04271 <false>)
   45: onread [net.js:~525] [pc=0x21a90839811a] (this=0xca7697e2dd1 <a TTY with map 0x9177672b921>#25#,nread=1,buffer=0x920c0214629 <an Uint8Array with map 0x9177672f4f1>#22#)
   46: arguments adaptor frame: 3->2
=====================


==== C stack trace ===============================

 1: v8::Template::Set(v8::Local<v8::Name>, v8::Local<v8::Data>, v8::PropertyAttribute)
 2: NeonSys_Class_AddMethod
 3: neon::internal::js::class::ClassInternal::metadata::h361eb70f2a05f743
 4: arx::__LOAD_NEON_MODULE::__init_neon_module::h7d638edf0aab2156
 5: neon::internal::vm::module_callback::h5212a5cd07e0aa07
 6: NeonSys_Module_ExecKernel
 7: neon::internal::vm::Module::initialize::hb5a9ebd00f144379
 8: node::DLOpen(v8::FunctionCallbackInfo<v8::Value> const&)
 9: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&))
10: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::(anonymous namespace)::BuiltinArguments<(v8::internal::BuiltinExtraArguments)1>)
11: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*)
12: 0x21a9082092a7

for code:

#[macro_use]
extern crate neon;
extern crate crypto;
extern crate rand;

use rand::Rng;
use neon::vm::{Lock};
use neon::mem::Handle;
use neon::js::binary::JsBuffer;
use neon::js::{JsFunction, JsObject, Object};
use neon::js::class::{JsClass, Class};

pub fn buf_copy_from_slice(data: &[u8], buf: &mut Handle<JsBuffer>) {
    buf.grab(|mut contents| {
        let slice = contents.as_mut_slice();

        slice.copy_from_slice(data);
    });
}

declare_types! {
    pub class Foo as Poo for () {
        init(_) {
            Ok(())
        }

        method snarf(call) {
            let scope = call.scope;

            let mut rand_slice = [0u8; 32];

            let mut rng = rand::OsRng::new().unwrap();
            rng.fill_bytes(&mut rand_slice);

            let mut rand_buf = try!(JsBuffer::new(scope, 32));

            buf_copy_from_slice(&rand_slice, &mut rand_buf);

            Ok(rand_buf.as_value())
        }
    }
}

register_module!(m, {
    let class: Handle<JsClass<Foo>> = try!(Foo::class(m.scope));
    let constructor: Handle<JsFunction<Foo>> = try!(class.constructor(m.scope));
    try!(m.exports.set("Poo", constructor));

    Ok(())
});

Then require the library.

🍻

@19h
Copy link
Author

19h commented Sep 11, 2016

Here's how Nan fixed it: nodejs/nan@a90951e.

@bgdavidx
Copy link

bgdavidx commented Oct 2, 2016

+1

as-cii pushed a commit to atom/neon that referenced this issue Oct 19, 2016
Fixes neon-bindings#119, which was causing hard crashes on newer
versions of node.
as-cii pushed a commit to atom/neon that referenced this issue Oct 19, 2016
Fixes neon-bindings#119, which was causing hard crashes on newer
versions of node.

Signed-off-by: Nathan Sobo <nathan@github.com>
@jedireza
Copy link
Contributor

jedireza commented Dec 23, 2016

Thanks for creating an issue. I've confirmed this shows up with node 6. This error doesn't show up for node 4 and I get the following error when running with node 7 (not sure if it's a different issue yet):

#
# Fatal error in ../deps/v8/src/api.cc, line 1051
# Check failed: !value_obj->IsJSReceiver() || value_obj->IsTemplateInfo().
#

I'm going to looking into the Nan solution and also see what #123 did to address this and try to land the fix.

@bnoordhuis
Copy link

@jedireza It's the same issue. Node v7 no longer prints the warning, it's a hard error now.

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

Successfully merging a pull request may close this issue.

4 participants