tangramdotdev / tangram

Tangram is a build system and package manager.
https://www.tangram.dev
MIT License
86 stars 6 forks source link

Panic in `lockfile.rs` when going to definition #325

Closed endbr64 closed 1 week ago

endbr64 commented 2 weeks ago
  1. cargo run -- serve
  2. Open this repo's tangram.ts in the editor.
  3. Go to definition of packages on line 19.
logs [dmitriy@ymir:~/work/git/tangram]$ cargo run -- serve Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.34s Running `target/debug/tangram serve` 2024-11-14T19:23:47.430153Z INFO tangram_server: listening on http+unix://%2Fhome%2Fdmitriy%2F.tangram%2Fsocket at packages/server/src/lib.rs:445 2024-11-14T19:23:59.482441Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/bun/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/bun"), path: Some("../packages/packages/bun"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "std" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.483893Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/bun/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/bun"), path: Some("../packages/packages/bun"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "std" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.491040Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/rust/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/rust"), path: Some("../packages/packages/rust"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "std" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.492077Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/rust/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/rust"), path: Some("../packages/packages/rust"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "std" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.493108Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/rust/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/rust"), path: Some("../packages/packages/rust"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "zlib" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.494216Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/rust/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/rust"), path: Some("../packages/packages/rust"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "./build.tg.ts" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.495330Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/rust/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/rust"), path: Some("../packages/packages/rust"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "./build.tg.ts" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.496321Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/rust/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/rust"), path: Some("../packages/packages/rust"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "./proxy.tg.ts" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.498373Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/rust/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/rust"), path: Some("../packages/packages/rust"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "./proxy.tg.ts" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.499459Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/rust/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/rust"), path: Some("../packages/packages/rust"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "./cargo.tg.ts" } } at packages/server/src/compiler/syscall/log.rs:6 2024-11-14T19:23:59.500494Z INFO tangram_server::compiler::syscall::log: NG0 { "message": "failed to resolve specifier relative to the module", "location": { "symbol": "tangram_server::compiler::syscall::module::resolve::{{closure}}::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/syscall/module.rs" }, "line": 32, "column": 4 }, "stack": undefined, "source": NG0 { "message": "failed to find lockfile", "location": { "symbol": "tangram_server::compiler::resolve::::resolve_with_path_referrer::{{closure}}", "source": { "kind": "internal", "value": "./packages/server/src/compiler/resolve.rs" }, "line": 248, "column": 14 }, "stack": undefined, "source": undefined, "values": { "module": "/home/dmitriy/work/git/packages/packages/rust/tangram.ts" } }, "values": { "referrer": "Module { kind: Ts, referent: Referent { item: Path("/home/dmitriy/work/git/packages/packages/rust"), path: Some("../packages/packages/rust"), subpath: Some("tangram.ts"), tag: None } }", "specifier": "./cargo.tg.ts" } } at packages/server/src/compiler/syscall/log.rs:6 thread 'tokio-runtime-worker' panicked at packages/server/src/lockfile.rs:199:12: index out of bounds: the len is 0 but the index is 0 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'tokio-runtime-worker' panicked at library/core/src/panicking.rs:221:5: panic in a function that cannot unwind stack backtrace: 0: 0x55555f29a7b5 - std::backtrace_rs::backtrace::libunwind::trace::h649ab3318d3445c5 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5 1: 0x55555f29a7b5 - std::backtrace_rs::backtrace::trace_unsynchronized::hf4bb60c3387150c3 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x55555f29a7b5 - std::sys::backtrace::_print_fmt::hd9186c800e44bd00 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:65:5 3: 0x55555f29a7b5 - ::fmt::h1b9dad2a88e955ff at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:40:26 4: 0x55555f2ca57b - core::fmt::rt::Argument::fmt::h351a7824f737a6a0 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/fmt/rt.rs:173:76 5: 0x55555f2ca57b - core::fmt::write::h4b5a1270214bc4a7 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/fmt/mod.rs:1182:21 6: 0x55555f29566f - std::io::Write::write_fmt::hd04af345a50c312d at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/io/mod.rs:1827:15 7: 0x55555f29bab1 - std::sys::backtrace::BacktraceLock::print::h68d41b51481bce5c at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:43:9 8: 0x55555f29bab1 - std::panicking::default_hook::{{closure}}::h96ab15e9936be7ed at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:269:22 9: 0x55555f29b78c - std::panicking::default_hook::h3cacb9c27561ad33 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:296:9 10: 0x55555f29c181 - std::panicking::rust_panic_with_hook::hfe205f6954b2c97b at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:800:13 11: 0x55555f29bfb3 - std::panicking::begin_panic_handler::{{closure}}::h6cb44b3a50f28c44 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:667:13 12: 0x55555f29ac79 - std::sys::backtrace::__rust_end_short_backtrace::hf1c1f2a92799bb0e at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:168:18 13: 0x55555f29bc74 - rust_begin_unwind at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5 14: 0x55555f2c7dc5 - core::panicking::panic_nounwind_fmt::runtime::h907a0444fa61a6dc at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:112:18 15: 0x55555f2c7dc5 - core::panicking::panic_nounwind_fmt::h4c4dc67d0bbc166c at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:122:5 16: 0x55555f2c7e52 - core::panicking::panic_nounwind::hb98133c151c787e4 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:221:5 17: 0x55555f2c8076 - core::panicking::panic_cannot_unwind::he9511e6e72319a3e at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:309:5 18: 0x55555a934cf6 - R as v8::support::CFnFrom>::mapping::c_fn::hfdcb282604e4ba39 at /home/dmitriy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/v8-130.0.1/src/support.rs:683:9 19: 0x55555dd7a1c6 - Builtins_CallApiCallbackGeneric thread caused non-unwinding panic. aborting. Aborted (core dumped)
endbr64 commented 1 week ago

The lockfile.nodes is empty in find_node_in_lockfile(), probably because some path lookup fails (probably because of ./). Added a check for this in #335 that will at least stop us from panicking.