Node: Access Violation

Created on 19 Jul 2019  路  3Comments  路  Source: nodejs/node

  • Version: v12.6.0
  • Platform: Windows 64-bit
  • Subsystem:

It is possible that I'm doing something wrong, but I believe the program should not crash.

By running the following code, the program crashes (most of the time) with C0000005.ACCESS_VIOLATION.

const { Worker } = require( "worker_threads" );

const workerCode = `
const v8 = require( "v8" );
const { parentPort } = require( "worker_threads" );

function share( contents ) {
  const shared = new SharedArrayBuffer( contents.length );
  const buffer = Buffer.from( shared );
  contents.copy( buffer );
  return shared;
}

function serialize( value ) {
  return share( v8.serialize( value ) );
}

parentPort.on( "message", () => {
  parentPort.postMessage( serialize( {} ) );
} );
`;

function createWorker( id ) {
  const child = new Worker( workerCode, {
    eval: true
  } );
  child.postMessage( {} );
  child.on( "message", () => {
    child.terminate();
  } );
  child.on( "error", err => console.error( "error", id, err ) );
  child.once( "exit", () => {
    console.log( "exit", id );
  } );
}

console.log( "5 secs..." );

setTimeout( () => {
  for ( let i = 0; i < 10; i++ ) {
    createWorker( i );
  }
}, 5000 );

I've used procdump64 -e node to produce a dump file (available in the following zip file).
node.exe_190719_222025.zip

Opening the dump file in Visual Studio, shows me this:

image

confirmed-bug worker

Most helpful comment

https://github.com/nodejs/node/pull/28788 should address this, thanks for reporting it!

All 3 comments

I'll be looking this one up, thanks.

https://github.com/nodejs/node/pull/28788 should address this, thanks for reporting it!

I found the the same problem,too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fanjunzhi picture fanjunzhi  路  3Comments

willnwhite picture willnwhite  路  3Comments

vsemozhetbyt picture vsemozhetbyt  路  3Comments

dfahlander picture dfahlander  路  3Comments

mcollina picture mcollina  路  3Comments