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

'openFile' fails due to race condition created by initialization of ZSTD library (nodejs) #318

Closed
graduta opened this issue Aug 21, 2024 · 5 comments
Assignees
Labels

Comments

@graduta
Copy link

graduta commented Aug 21, 2024

Hi,

I am writing about an issue with how the initialization of selected ZSTD library ZSTD is done in io.mjs which causes a race condition (for ZstdInit() which in turn makes JSROOT unable to plot any objects due to bad initialization which makes the subsequent decompression method fail all the time.

Replicate Environment:

  • OS: MacOS and RedHat
  • NodeJS: v20.11 and v20.12
  • JSROOT: 7.6.0 and onwards
  • JSROOT usage: The project involves using JSROOT on the back-end side (NodeJS) installed via NPM

Steps to replicate in a NodeJS script:

  1. Import openFile method import { openFile } from 'jsroot';
  2. Make 2 calls to the openFile method without waiting one on another to open 2 files.
  3. ZSTD decompression will fail due to the fact that ZstdInit() is called two times without having the chance to finish.
  4. ZSTD error generated for initial two and any further openFile
RuntimeError: abort(Error: ZSTD_ERROR: Src size is incorrect,  error code: -72) at Error
    at /node_modules/@oneidentity/zstd-js/lib/index.cjs.js:16:1686449
    at process.j (/node_modules/@oneidentity/zstd-js/lib/index.cjs.js:16:1686578)
    at process.emit (node:events:530:35)
    at emit (node:internal/process/promises:150:20)
    at processPromiseRejections (node:internal/process/promises:284:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)
    at process.j (/node_modules/@oneidentity/zstd-js/lib/index.cjs.js:16:1686723)
    at process.emit (node:events:530:35)
    at emit (node:internal/process/promises:150:20)
    at processPromiseRejections (node:internal/process/promises:284:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)

Error in NPM project using JSROOT:

Error: ZSTD_ERROR: Src size is incorrect,  error code: -72
    at A.checkError (<project_path>/node_modules/@oneidentity/zstd-js/lib/index.cjs.js:16:2561974)
    at A.decompress (<project_path>/node_modules/@oneidentity/zstd-js/lib/index.cjs.js:16:2565439)
    at file://<project_path>/node_modules/jsroot/modules/io.mjs:2037:41
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
@linev linev self-assigned this Aug 21, 2024
linev added a commit that referenced this issue Aug 21, 2024
While ZSTD decoding can be invoked
from different places, ensure that initialization performed properly.
@linev linev added the bug label Aug 21, 2024
@linev
Copy link
Member

linev commented Aug 21, 2024

Can you try master branch of JSROOT?
If it works - I can backport fix to 7.7 branch

@graduta
Copy link
Author

graduta commented Aug 21, 2024

Hi, thank you for the quick fix!
I checked out master branch and the script is not having any issues anymore.

linev added a commit that referenced this issue Aug 21, 2024
While ZSTD decoding can be invoked
from different places, ensure that initialization performed properly.
@linev
Copy link
Member

linev commented Aug 21, 2024

I backport fix to 7.7 branch.
Do you need released version for it?

@graduta
Copy link
Author

graduta commented Aug 21, 2024

There is no rush for me now. I downgraded my deployment to using JSROOT 7.5.5 and I am ok with waiting until the next JSROOT release

@linev
Copy link
Member

linev commented Aug 23, 2024

Resolved in 7.7.3 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants