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

libc++abi: terminating due to uncaught exception of type std::out_of_range: basic_string Abort trap: 6 #801

Closed
Leask opened this issue May 5, 2023 · 3 comments

Comments

@Leask
Copy link

Leask commented May 5, 2023

Crash while parsing some pages. It's easy to reproduce:

let { Readability } = require('./index.js');
let { JSDOM } = require('jsdom');

const url = 'https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html';

(async () => {
    const resp = await fetch(url);
    const html = Buffer.from(await resp.arrayBuffer()).toString('utf8');
    const doc = new JSDOM(html);
    const reader = new Readability(doc.window.document);
    const article = reader.parse();
    console.log(article);
})();

Crash with logs:

libc++abi: terminating due to uncaught exception of type std::out_of_range: basic_string
Abort trap: 6

Screenshot:

Screenshot 2023-05-05 at 12 48 22 PM

Debug codes can be found here:

https://github.com/Leask/readability/blob/out_of_range/debug.js

Leask added a commit to Leask/utilitas that referenced this issue May 5, 2023
Leask added a commit to Leask/halbot that referenced this issue May 5, 2023
@gijsk
Copy link
Contributor

gijsk commented May 5, 2023

I mean, it's hard to see how a JS library with no C++ components could have caused a C++ crash, short of a bug in the node/js engine.

Have you tried bisecting the snippet and ensured the crash isn't in the setup code? Or tried different versions of nodejs? The debug.js snippet works fine on v19.5.0 on my mac, so I'd suggest this is an issue in your nodejs binary (is it self-compiled or provided by something else?) and/or version. If it's an official nodejs executable (rather than self-compiled) I'd suggest filing a bug with them.

@gijsk gijsk closed this as completed May 5, 2023
@Leask
Copy link
Author

Leask commented May 5, 2023

Yes, you are right. I went deeper this afternoon and discovered the issue is on Node.js v20. And it's straightforward to reproduce.

new URL('..#', 'a:b');
libc++abi: terminating due to uncaught exception of type std::out_of_range: basic_string
Abort trap: 6

But I am sad that you seem not curious why the code can run on Node.js v19 but crash on v20.

I understand your point, and I will go to the Node.js repo to submit this issue and help them resolve it.

Thanks for your reply.

@gijsk
Copy link
Contributor

gijsk commented May 5, 2023

But I am sad that you seem not curious why the code can run on Node.js v19 but crash on v20.

Well, first of all, I didn't have a copy of Node v20 handy, so I simply couldn't reproduce. I also wasn't sure that it would be reproducible even if I did spend time to try to recreate the environment (often platform or ABI or environment/library differences, or differences in the markup that fetch call produces could result in it working fine for me even when it clearly doesn't for you).

I get on the order of 100 emails a day regarding software I have some level of responsibility for, so if it's clear that it's not my wheelhouse, I usually cannot afford the time to dig into it.

I understand your point, and I will go to the Node.js repo to submit this issue and help them resolve it.

Thanks and good luck! I hope the node.js folks resolve this soon - it shouldn't be possible to crash the JS environment with simple JS like this.

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

No branches or pull requests

2 participants