You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! This is a weird one. Either there is something I fundamentally didn't understood in the doc, or there is a very weird glitch.
So: I wanted to use simd-json to output a simple json. Here is the code:
use simd_json::json;fnmain(){let test = json!({"hello":"world","anInt":123,});let test_str = simd_json::to_string_pretty(&test).unwrap();println!("{test_str}");}
The expected output should have been:
{
"hello": "world",
"anInt": 213
}
But instead ALL the string (object keys or values) are duplicated. I get this:
{
"hellohello": "worldworld",
"anIntanInt": 123
}
I tried with a array of string, and I get duplicated string also:
[
"testtest",
"a_valuea_value"
]
Same thing if I just try to encode a single string.
My (ignorant) hunch
I am running this code on a VM inside a server. Running the exact same code on my laptop doesn't show this bug.
So, considering that this makes heavy use of simd instruction and that simd instruction are plateform specific, it seems like there is some f-ery going on with the feature detection / instruction used ? Probably caused by running inside a VM ?
Plateform information
Considering that this bug is very likely plateform specific, I will try to give as much info as I can.
I don't have direct access to the server the VM is running on so I will need to ask the admin for the server info.
OS (VM)
-> % lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
-> % uname -a
Linux newworld 6.1.0-22-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.94-1 (2024-06-21) x86_64 GNU/Linux
Create a new binary project with cargo new test_json
Add the simd_json crate with cargo add simd-json
In the main.rs use the following code:
use simd_json::json;fnmain(){let test = json!({"hello":"world","anInt":123,});let test_str = simd_json::to_string_pretty(&test).unwrap();println!("{test_str}");}
cargo run and get the following result:
{
"hellohello": "worldworld",
"anIntanInt": 123
}
The text was updated successfully, but these errors were encountered:
Found some of the server info:
Host CPU: 8 x Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (1 Socket)
Host Kernel: Linux 5.15.107-2-pve #1 SMP PVE 5.15.107-2 (2023-05-10T09:10Z)
VM Management system: Proxmox / pve-manager/7.4-3/9002ab8a
This seems to be indeed caused by the VM. In the proxmox VM hardware option, I changed the processors type from the generic "kvm64" to the more specific "Skylake-Client-noTSX-IBRS" which match the actual host CPU, and wouldn't you know it: The bug is fixed!
Since it does seems to be an issue with feature detection, I could close this ticket, but since I don't know much about feature detection, I will let any contributor decide if this issue should be closed, and/or reported else where (or if it is intended due to the VM cpu being set to kvm64 messing with the FD).
This is definitely a bug. Thanks for the excellent report 😊. Let's leave it open since it should work without the user needing to change virtualization settings or even think about it. I'll dig into it and try to fix it in a way that doesn't require user actions
Description
Hello! This is a weird one. Either there is something I fundamentally didn't understood in the doc, or there is a very weird glitch.
So: I wanted to use
simd-json
to output a simple json. Here is the code:The expected output should have been:
But instead ALL the string (object keys or values) are duplicated. I get this:
I tried with a array of string, and I get duplicated string also:
Same thing if I just try to encode a single string.
My (ignorant) hunch
I am running this code on a VM inside a server. Running the exact same code on my laptop doesn't show this bug.
So, considering that this makes heavy use of simd instruction and that simd instruction are plateform specific, it seems like there is some f-ery going on with the feature detection / instruction used ? Probably caused by running inside a VM ?
Plateform information
Considering that this bug is very likely plateform specific, I will try to give as much info as I can.
I don't have direct access to the server the VM is running on so I will need to ask the admin for the server info.
OS (VM)
CPU (as seen by the VM)
Rust
Step to reproduce
cargo new test_json
cargo add simd-json
The text was updated successfully, but these errors were encountered: