rhaiscript / lsp

Language server for Rhai.
Apache License 2.0
43 stars 4 forks source link

Incorrect characters in insta snapshots #102

Open tamasfe opened 1 year ago

tamasfe commented 1 year ago

Weird characters appear seemingly randomly in formatter output snapshots that I haven't been able to reproduce outside tests.

image

tamasfe commented 1 year ago

I suspected that it was an use-after-free error due to the way handle strings in the formatter: https://github.com/rhaiscript/lsp/blob/c954855412d59702ea939c677f501ae28d9a3d29/crates/rhai-fmt/src/util.rs#L122

But miri does not complain about it.

schungx commented 1 year ago

I suspected that it was an use-after-free error due to the way handle strings in the formatter:

I wonder how this can happen with Rust... Is it unsafe code?

tamasfe commented 1 year ago

I suspected that it was an use-after-free error due to the way handle strings in the formatter:

I wonder how this can happen with Rust... Is it unsafe code?

Yes, what I linked is unsafe :). But it appears to be correct and isn't the cause.