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

Cannot render vector artifact: recursive use of an object detected which would lead to unsafe aliasing in rust #515

Open
OverflowCat opened this issue Apr 13, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@OverflowCat
Copy link

Describe the bug
When rendering artifact in SVG mode, the renderer throws Error: recursive use of an object detected which would lead to unsafe aliasing in rust.

To Reproduce

Compile a hello world using CLI (v0.4.1)[https://github.com/Myriad-Dreamin/typst.ts/releases/tag/v0.4.1].

Render the main.artifact.sir.in artifact using the node.js-next example, or $typst.svg({ vectorData }) in all-in-one.

node ./dist/esm/main.js
panicked at crates\reflexo\src\vector\stream.rs:38:69:
called `Result::unwrap()` on an `Err` value: CheckBytesError(StructCheckError { field_name: "metadata", inner: ContextError(ArchiveError(SubtreePointerOutOfBounds { ptr: 0x132268, subtree_range: 0x130270..0x132260 })) })

Stack:

Error
    at file:///████████/typst.ts/templates/node.js-next/node_modules/.pnpm/@[email protected]/node_modules/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer.mjs:1567:21
    at logError (file:///████████/typst.ts/templates/node.js-next/node_modules/.pnpm/@[email protected]/node_modules/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer.mjs:225:18)
    at imports.wbg.__wbg_new_abda76e883ba8a5f (file:///████████/typst.ts/templates/node.js-next/node_modules/.pnpm/@[email protected]/node_modules/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer.mjs:1566:66)
    at wasm://wasm/0043af92:wasm-function[1835]:0xedbc5
    at wasm://wasm/0043af92:wasm-function[865]:0xc2c71
    at wasm://wasm/0043af92:wasm-function[1396]:0xe5aff
    at wasm://wasm/0043af92:wasm-function[1202]:0xdb203
    at wasm://wasm/0043af92:wasm-function[313]:0x7251e
    at wasm://wasm/0043af92:wasm-function[302]:0x6dbd2
    at wasm://wasm/0043af92:wasm-function[547]:0xa77d5


file:///████████/typst.ts/templates/node.js-next/node_modules/.pnpm/@[email protected]/node_modules/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer.mjs:1973
        throw new Error(getStringFromWasm0(arg0, arg1));
              ^

Error: recursive use of an object detected which would lead to unsafe aliasing in rust
    at imports.wbg.__wbindgen_throw (file:///████████/typst.ts/templates/node.js-next/node_modules/.pnpm/@[email protected]/node_modules/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer.mjs:1973:15)
    at wasm://wasm/0043af92:wasm-function[1817]:0xebda2
    at wasm://wasm/0043af92:wasm-function[1816]:0xebd97
    at wasm://wasm/0043af92:wasm-function[715]:0xb95ce
    at RenderSession.free (file:///████████/typst.ts/templates/node.js-next/node_modules/.pnpm/@[email protected]/node_modules/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer.mjs:784:14)
    at TypstRendererDriver.runWithSession (file:///████████/typst.ts/templates/node.js-next/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@myriaddreamin/typst.ts/dist/esm/renderer.mjs:567:21)
    at async main (file:///████████/typst.ts/templates/node.js-next/dist/esm/main.js:15:17)

Desktop (please complete the following information):

  • macOS v13.6 (22G120)
  • Node.js v21.6.2

Package/Software version (using command typst-ts-cli --VV full and paste down the output):

typst-ts-cli version 0.4.1
features: embedded_cjk_fonts embedded_emoji_fonts embedded_fonts gen_manual pdf serde_json serde_rmp svg text

program-ver: v0.4.1-dirty
program-rev: 58f88e9842905d70c6822e8fd2db8b3e9a59be27
program-build: aarch64-apple-darwin with opt_level(3) at 2023-12-05T03:06:40.180010000Z

rustc-ver: 1.74.0
rustc-rev: 79e9716c980570bfd1f666e3b16ac583f0168962
rustc-build: x86_64-apple-darwin-stable with LLVM 17.0
@Myriad-Dreamin
Copy link
Owner

The typst-ts-cli must have exact same version as the version which you specified in the in typst.ts, otherwise you will get a CheckBytesError error. For example, if the typst.ts is installed as 0.5.0-rc2, the typst-ts-cli must be also 0.5.0-rc2.

@OverflowCat
Copy link
Author

Thanks for clarifying! It would be even better if this requirement was prominently noted in the documentation or if there was a version check for the artifact.

@Myriad-Dreamin Myriad-Dreamin added the documentation Improvements or additions to documentation label Apr 16, 2024
@Myriad-Dreamin
Copy link
Owner

Myriad-Dreamin commented Apr 16, 2024

I was considering adding a notes, but I don't know where to add it, as you may be missing it for some reason and ask again. From a short reconsideration, I would like to add it to the "Troubleshooting" page.

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

No branches or pull requests

2 participants