Try changing the String::New("Buffer") part to String::NewSymbol("Buffer").

Idk why, but that fixed some seg faults I was experiencing using similar
code.

On Wed, Jun 6, 2012 at 12:11 AM, Denys Khanzhiyev <xden...@gmail.com> wrote:

> I definetelly shoot myself in my leg somewhere
>
> when i change code like that
>
> HandleScope scope;
> Local<Value> js_field = Local<Value>::New(Null());
>
> ....
>
> js_field = String::New((const char*)(vary2->vary_string));
>
>
> ...
> return scope.Close(js_field);
>
> to code like that
>
> HandleScope scope;
> Local<Value> js_field = Local<Value>::New(Null());
>
>
> ....
> Buffer *slowBuffer = Buffer::New(vary2->vary_length);
> memcpy(Buffer::Data(slowBuffer), (const char*)(vary2->vary_string), 
> vary2->vary_length);
>
> Local<Object> globalObj = Context::GetCurrent()->Global();
>
> Local<Function> bufferConstructor = 
> Local<Function>::Cast(globalObj->Get(String::New("Buffer")));
>
> Handle<Value> constructorArgs[3] = { slowBuffer->handle_, 
> Integer::New(vary2->vary_length), Integer::New(0) };
>
> js_field = bufferConstructor->NewInstance(3, constructorArgs);
>
> ...
> return scope.Close(js_field);
>
> i.e. returns Buffer instead of String.
> Node strarts to fall with segmentation fault unconditionally. I call that
> method in a loop. The problem may appear after 100 iterations or after
> 10000. The input data are same for both cases.
> Am I doing something wrong?
>
>
> 2012/6/5 Denys Khanzhiyev <xden...@gmail.com>
>
>> gdb --args ./node_g ../node_firebird/issues/issue10.js
>> GNU gdb (GDB) CentOS (7.0.1-42.el5.centos)
>> Copyright (C) 2009 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later <
>> http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "i386-redhat-linux-gnu".
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>...
>> Reading symbols from /root/node/node_g...(no debugging symbols
>> found)...done.
>>
>> Trying to catch segfault and all I get in backtrace
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x578bbeaa in ?? ()
>> (gdb) backtrace
>> #0  0x578bbeaa in ?? ()
>> #1  0x4aaeb361 in ?? ()
>> #2  0x478517a1 in ?? ()
>> #3  0x578bbe61 in ?? ()
>> #4  0x0000000c in ?? ()
>> #5  0x578acf46 in ?? ()
>> #6  0x00000000 in ?? ()
>>
>> ]# ./node_g -v
>> v0.6.13
>>
>> built with
>>  ./configure --debug
>> make
>>
>> any help?
>>
>> Thank you!
>>
>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to