Skip to content

fix: String may be written twice in one codepath#65

Open
EmilyMatt wants to merge 1 commit intosimd-lite:mainfrom
EmilyMatt:fix-duplicate-write
Open

fix: String may be written twice in one codepath#65
EmilyMatt wants to merge 1 commit intosimd-lite:mainfrom
EmilyMatt:fix-duplicate-write

Conversation

@EmilyMatt
Copy link

@EmilyMatt EmilyMatt commented Feb 24, 2026

This was discovered by running miri on simd-json.
Test serde::se::pp::test::prettyfy

After lengthy debugging, following codepath is required:

  1. runtime-detection is enabled
  2. x86 architecture
  3. No avx2 available on system
  4. No sse2 available on system
  5. portable is disabled

In that code path we end up calling write_string_rust twice.
But the first one does not advance the string, so we end up writing the same string twice.
The solutions is to move the *string = &string[string.len()..]; line into write_string_rust() itself

Closes #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

write_str_simd_fastest can accidentally write strings twice. under miri

1 participant