-
Notifications
You must be signed in to change notification settings - Fork 26
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
Segmentation fault when running inside worker threads (Ubuntu) #64
Comments
Thank you for the reproduction! Will dig into this. |
I just tested your exact example and it works if you use It seems that the issue is not necessarily related to I wonder if this was previously working with an older version of libpg-query? |
I think it happens when const { Worker, isMainThread, parentPort, workerData } = require("node:worker_threads");
if (isMainThread) {
function run(query) {
return new Promise((resolve, reject) => {
const worker = new Worker(__filename, { workerData: query });
worker.on("message", resolve);
worker.on("error", reject);
worker.on("exit", (code) => {
if (code !== 0) reject(new Error(`Worker stopped with exit code ${code}`));
});
});
};
run("select 1 as x").then(x => console.log(x))
} else {
const { parseQuerySync } = require("libpg-query");
const query = workerData;
parentPort.postMessage(parseQuerySync(query));
} |
Issue
When I run the following test:
The test passes, and I get the parsed query, but the process exists with error code 139:
(see execution - https://github.com/Newbie012/test-libpg-query-seg-fault/actions/runs/9091229513/job/24985419636)
Expected
Should not throw segmentation fault
Reproduction:
git clone [email protected]:Newbie012/test-libpg-query-seg-fault.git
pnpm install
pnpm test
Additional info
The text was updated successfully, but these errors were encountered: