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

fix: segfaults when used with worker_threads #24

Merged
merged 2 commits into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,17 @@ jobs:
os:
- macos-latest
- ubuntu-latest
- windows-latest
- windows-2019
steps:
- name: Fetch code
uses: actions/checkout@v1
with:
submodules: true

- name: Install dependencies
run: yarn install --ignore-scripts

- name: Build addon
if: runner.os != 'Linux'
run: make build-addon

- name: Build addon
if: runner.os == 'Linux'
run: make build-addon-linux

- name: Get minimal Node.js version from package.json (Linux & macOS)
id: node-version-nix
if: runner.os != 'Windows'
run: echo "::set-output name=version::$(node -p 'require("./package.json").engines.node.match(/(\d.*)$/)[0]')"
run: echo "::set-output name=version::$(node -p 'require("./package.json").engines.node.match(/(\d+)\..*$/)[1]')"

- name: Use Node.js ${{ steps.node-version-nix.outputs.version }} (Linux & macOS)
if: runner.os != 'Windows'
Expand All @@ -46,14 +35,25 @@ jobs:
- name: Get minimal Node.js version from package.json (Windows)
id: node-version-win
if: runner.os == 'Windows'
run: echo "::set-output name=version::$(node -p 'require(\"./package.json\").engines.node.match(/(\d.*)$/)[0]')"
run: echo "::set-output name=version::$(node -p 'require(\"./package.json\").engines.node.match(/(\d+)\..*$/)[1]')"

- name: Use Node.js ${{ steps.node-version-win.outputs.version }} (Windows)
if: runner.os == 'Windows'
uses: actions/setup-node@v1
with:
node-version: ${{ steps.node-version-win.outputs.version }}

- name: Install dependencies
run: yarn install --ignore-scripts

- name: Build addon
if: runner.os != 'Linux'
run: make build-addon

- name: Build addon
if: runner.os == 'Linux'
run: make build-addon-linux

- name: Run tests for addon
run: make test-tap

Expand Down
6 changes: 0 additions & 6 deletions src/addon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class KeccakWrapper : public Napi::ObjectWrap<KeccakWrapper> {

private:
KeccakWidth1600_SpongeInstance sponge;
static Napi::FunctionReference constructor;

Napi::Value Initialize(const Napi::CallbackInfo& info);
Napi::Value Absorb(const Napi::CallbackInfo& info);
Expand All @@ -21,8 +20,6 @@ class KeccakWrapper : public Napi::ObjectWrap<KeccakWrapper> {
Napi::Value Copy(const Napi::CallbackInfo& info);
};

Napi::FunctionReference KeccakWrapper::constructor;

Napi::Object KeccakWrapper::Init(Napi::Env env) {
Napi::Function func =
DefineClass(env,
Expand All @@ -36,9 +33,6 @@ Napi::Object KeccakWrapper::Init(Napi::Env env) {
InstanceMethod("copy", &KeccakWrapper::Copy),
});

constructor = Napi::Persistent(func);
constructor.SuppressDestruct();

return func;
}

Expand Down