Panic when using `rayIntersect`
Author: mcartonCreated May 6, 2025Updated May 6, 2025
Describe the bug
roger panic and the web interface shows error (RuntimeError) when compiling the following example. Output from Roger:
panicked at 'NaN in xs', packages/optimizer/src/lib.rs:353:17
Stack:
Error
at imports.wbg.__wbg_new_abda76e883ba8a5f (file:///usr/local/lib/node_modules/@penrose/roger/node_modules/@penrose/optimizer/dist/index.js:337:17)
at console_error_panic_hook::hook::hcefd4cc281690f23 (wasm://wasm/000ab84e:wasm-function[111]:0x15cdd)
at core::ops::function::Fn::call::hfa821b8726737154 (wasm://wasm/000ab84e:wasm-function[430]:0x1eae1)
at std::panicking::rust_panic_with_hook::h6df5db7ad9f65dc8 (wasm://wasm/000ab84e:wasm-function[185]:0x1b5ea)
at std::panicking::begin_panic_handler::{{closure}}::h0d169fa297411d6d (wasm://wasm/000ab84e:wasm-function[204]:0x1c3c3)
at std::sys_common::backtrace::__rust_end_short_backtrace::h7fe51fb4d3ba6060 (wasm://wasm/000ab84e:wasm-function[425]:0x1eab8)
at rust_begin_unwind (wasm://wasm/000ab84e:wasm-function[244]:0x1d5b1)
at core::panicking::panic_fmt::h2d3c5586175098d9 (wasm://wasm/000ab84e:wasm-function[267]:0x1dc4a)
at penrose_optimizer::lbfgs::step_until::h20ed929a5753cbd9 (wasm://wasm/000ab84e:wasm-function[55]:0x26a0)
at penrose_step_until (wasm://wasm/000ab84e:wasm-function[56]:0x3a5f)
roger trio [trio..]
Generate a diagram from a Penrose trio.
Options:
--version Show version number [boolean]
--help Show help [boolean]
--trio Three files pointing to a Penrose trio or a JSON file that l
inks to them. [array] [required]
-o, --out Name of the output SVG file. [string]
-p, --path A common path prefix for the trio files [default: "."]
--tex-labels Render Equation shapes as plain TeX strings in the output SV
G [boolean] [default: false]
-v, --variation Variation for the Penrose diagram [string]
RuntimeError: unreachable
at __rust_start_panic (wasm://wasm/000ab84e:wasm-function[454]:0x1eb9a)
at rust_panic (wasm://wasm/000ab84e:wasm-function[370]:0x1e81e)
at std::panicking::rust_panic_with_hook::h6df5db7ad9f65dc8 (wasm://wasm/000ab84e:wasm-function[185]:0x1b617)
at std::panicking::begin_panic_handler::{{closure}}::h0d169fa297411d6d (wasm://wasm/000ab84e:wasm-function[204]:0x1c3c3)
at std::sys_common::backtrace::__rust_end_short_backtrace::h7fe51fb4d3ba6060 (wasm://wasm/000ab84e:wasm-function[425]:0x1eab8)
at rust_begin_unwind (wasm://wasm/000ab84e:wasm-function[244]:0x1d5b1)
at core::panicking::panic_fmt::h2d3c5586175098d9 (wasm://wasm/000ab84e:wasm-function[267]:0x1dc4a)
at penrose_optimizer::lbfgs::step_until::h20ed929a5753cbd9 (wasm://wasm/000ab84e:wasm-function[55]:0x26a0)
at penrose_step_until (wasm://wasm/000ab84e:wasm-function[56]:0x3a5f)
at penrose_step_until (file:///usr/local/lib/node_modules/@penrose/roger/node_modules/@penrose/optimizer/dist/index.js:215:20)To Reproduce
Using 3.2.0 or roger, or the current web version at https://penrose.cs.cmu.edu/try/ and the following files:
-- Substance
Application A-- Domain
type Application-- Style
canvas {
width = 400
height = 400
}
forall Application v {
v.rect1 = Rectangle {
width: 10
height: 10
}
v.rect2 = Rectangle {
width: 10
height: 10
}
}
forall Application u {
asdf = rayIntersect(u.rect1, u.rect1.center, u.rect2.center - u.rect1.center)
adfasd = Line {
start: u.rect1.center
end: asdf
}
}Expected behavior
No panic. A line should be drawn to the edge of rect2 from the center of rect1. The web interface generates the correct image despite the error. roger prints the aforementioned error and does not output a file.
Source: penrose/penrose