cryptocoinjs / keccak

Keccak sponge function family
MIT License
87 stars 24 forks source link

fix: segfaults when used with worker_threads #24

Closed mariuspod closed 1 year ago

mariuspod commented 1 year ago

This PR makes the lib more robust when used in combination with worker_threads. We've observed that the usage of the global constructor field is not thread-safe and may lead to segfaults.

Fixes issue: #19

Minimal segfaulting example without this change:

const wt = require('worker_threads');
const foo = require('keccak');

if(wt.isMainThread) {
  for(let i = 0; i < 100; i++) {
    new wt.Worker(__filename);
  }
}
fanatid commented 1 year ago

Sorry for the delay! It's great! Can you fix CI? Probably we should bump node.js version? :thinking: (same for secp256k1-node)

fanatid commented 1 year ago

macos failed (windows probably too) :disappointed:

fanatid commented 1 year ago

adjusted actions policy, hope that will not need to approve CI on each push :slightly_smiling_face:

fanatid commented 1 year ago

Published as v3.0.3, thank you!