-
-
Notifications
You must be signed in to change notification settings - Fork 11
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 using a custom item #80
Comments
@kelvinhammond One hour ago, I have updated the build script to use libzim |
@kelson42 Nice, will try again. I wonder if they fixed it! Thank you. I should have a bit more time soon (hopefully) to take a look at this and mwoffliner during the holidays. |
@kelvinhammond Thx, would be really helpful to know soon if this critical bug is really fixed or if I just don't run the reproduction case steps properly. |
@kelson42 Try it with these changes The diff looks like this.
|
I tested it with node v19.1.0 I get
Looking into this more. |
@kelson42 It does work, just not with custom items. |
@kelvinhammond Sorry for the big delay in answering. I have involved @mgautierfr who is the lead developer of the libzim. Could you please elaborate what are these "custom items". This is not a concept of the libzim and therefore this is a bit puzzling. One important other point is if we really need them (does that impact MWoffliner)? |
BTW @uriesk, this is the bug which stops us to use latest libzim in MWoffliner (we are stuck with libzim6 which is18 months old). If you like to be challenged, this might be one for you ;) |
@kelson42 In libzim you can create Item(s) which have each have a |
@kelvinhammond But we don't need this customItem in MWoffliner? You confirm? |
I'll test a large file using only StringItem and FileItem to confirm it works but yes, mwoffliner does not use the custom item and content providers |
@kelvinhammond This would be a good news. Waiting to your confirmation. If confirmed, we could consider to release with this bug/limitation. |
sorry, it's out of my league. |
@mgautierfr Do you confirm this (not sure this is exactly how things work at the libzim)? Maybe there is a few things to know and check if using a custom provider? |
One important thing to remember is that the ContentProvider returned by libzim will use the I don't know how napi wrap things. But here : https://github.com/openzim/node-libzim/blob/main/test/makeLargeZim.ts#L54-L62, your custom item return a contentProvider which contain a closure as Maybe you can try this custom item which not create closure (but copy (reference to?) data): const customItem = { // custom item
path: url,
mimeType: "text/html",
title: title,
hints: {FRONT_ARTICLE: 1},
item_data: data, // reference directly the data without closure
getContentProvider() { // custom content provider
return {
size: this.item_data.length,
data_to_send: this.item_data, // same here, we don't want the feed() method being a closure accessing the `item_data` in customItem which will be deleted.
sent = false,
feed() {
if(!this.sent) {
this.sent = true;
return new Blob(this.data_to_send);
}
return new Blob();
}
};
},
}; |
@kelvinhammond Does that help? Do we have anything preventing the data to be freed? |
@kelson42 Sadly, it did not. I store a reference to the objects and functions in node so it "should" keep a copy of it in memory without garbage collecting it. The error also seems to happen (most of the time) when the object is creating a thread safe function callback. As for the |
You mean with a big wikipedia and your PR? |
Considering that this bug does not impact our current scrapers AFAIK, I propose to release 3.0.0 with this bug, so we can move forward and benefit from all the work already done. @kelvinhammond @mgautierfr Any thpughts? |
Sure, release it but include a note in the change notes please. |
In libzim v8 when using a custom item and adding a lot of objects to a zim file it will throw a segmentation fault error after about 10,000 items have been inserted.
The error has been reported to nodejs/node-addon-api below.
It appears to be related to:
To reproduce the error modify
tests/makeLargeZim.ts
file to use the custom item and run the test, it should fail.The issue has been reported to nodejs/node-addon-api#1174 .
Related to #72
The text was updated successfully, but these errors were encountered: