镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Closed

Description

@Leask

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

Activity

  1. gijsk commented on May 5, 2023

    @gijsk
    Contributor

    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.

  2. Leask commented on May 5, 2023

    @Leask
    Author

    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.

  3. gijsk commented on May 5, 2023

    @gijsk
    Contributor

    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.

  4. added a commit that references this issue on Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions