parcel-bundler / lightningcss

An extremely fast CSS parser, transformer, bundler, and minifier written in Rust.
https://lightningcss.dev
Mozilla Public License 2.0
6.52k stars 189 forks source link

[Bug] Parse css sheet occur "fatal runtime error: stack overflow" #827

Closed GiveMe-A-Name closed 3 weeks ago

GiveMe-A-Name commented 1 month ago
# Cargo.toml
[dependencies]
lightningcss = { version = "=1.0.0-alpha.58", features = [
  "sourcemap",
  "browserslist",
  "visitor",
  "into_owned",
] }
// main.rs
use lightningcss::stylesheet::{ParserFlags, ParserOptions, StyleSheet};
fn main() {

    let code = "h1 { left: calc(100% - 16px - 0);}";

    let flag = ParserFlags::empty();

    let options = ParserOptions {
        filename: "abc".to_string(),
        css_modules: None,
        source_index: 0,
        error_recovery: false,
        warnings: None,
        flags: flag,
    };

    let style_sheet = StyleSheet::parse(code, options).unwrap();
}

It occur system error: fatal runtime error: stack overflow, when cargo run

GiveMe-A-Name commented 1 month ago

Fixed by: https://github.com/parcel-bundler/lightningcss/pull/832