robo-todd opened a new issue, #2932:
URL: https://github.com/apache/fory/issues/2932

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/fory/issues) 
and found no similar issues.
   
   
   ### Version
   
   Environment:
   Fory 0.13.0 also Fory 0.13.1
   Rust 1.90
   Linux/x86_64
   
   In the example program attached, which is intended to be a simple variation 
on the existing unit test named "test_mixed_any_types" and 
"test_arc_dyn_any_shared_reference", I get multiple _different_ failures that 
are _different_ each time I run the program. I would not expect that kind of 
instability so I'm posting this as a bug.
   
   ```
   
   use std::any::Any;
   use fory::{Fory, ForyObject};
   
   #[derive(ForyObject, Debug, Clone)]
   #[repr(C)]
   pub struct StructA {
       a: i32,
   }
   
   // Different type with same fields. Problem happens regardless of fields.
   #[derive(ForyObject, Debug, Clone)]
   #[repr(C)]
   pub struct StructB {
       i: i32,
   }
   
   fn main() {
       let mut fory = Fory::default();
       // It doesn't matter if I use names or numbers for registration.
       fory.register_by_name::<StructA>("StructA").unwrap();
       // Without this it fails to serialize at runtime.
       fory.register_generic_trait::<Vec<StructA>>().unwrap();
   
       // It doesn't matter if I use names or numbers for registration.
       fory.register_by_name::<StructB>("StructB").unwrap();
       // Without this it fails to serialize at runtime.
       fory.register_generic_trait::<Vec<StructB>>().unwrap();
   
   
       // Fails?
       boom(& fory);
       println!("All good!");
   }
   
   
   fn boom(fory: & Fory) {
       let a_vec : Box<dyn Any> = Box::new(vec![StructA { a: 11 }; 5]);
       let b_vec : Box<dyn Any> = Box::new(vec![StructB { i: 1 }; 5]);
       let  mut any_vec : Vec<Box<dyn Any>> = Vec::new();
       any_vec.push(a_vec);
       any_vec.push(b_vec);
   
   
       println!("Serialize...");
       let bytes = fory.serialize(&any_vec).unwrap();
   
       println!("Deserialize...");
       // This fails at runtime with:
       // called `Result::unwrap()` on an `Err` value: TypeMismatch(4, 17)
       let deserialized : Vec<Box<dyn Any>> = fory.deserialize(&bytes).unwrap();
       assert_eq!(deserialized.len(), 2);
       let first_vec = deserialized[0].downcast_ref::<Vec<StructA>>().unwrap();
       let second_vec = deserialized[1].downcast_ref::<Vec<StructB>>().unwrap();
   }
   
   ```
   
   ### Component(s)
   
   Rust
   
   ### Minimal reproduce step
   
   Cargo build and run attached files vs. fory 0.13.0, fory 0.13.1 on Rust 1.90.
   
   
   ### What did you expect to see?
   
   Successful run with no errors.
   
   ### What did you see instead?
   
   Inconsistent results, with different kinds of failures on successive runs of 
the exact same binary program. Seems like memory or buffer corruption or 
something going on.
   
   
   For some reason it can't de-serialize what it serialized:
   
   ```
   ./target/debug/fory_issue
   Serialize...
   Deserialize...
   
   thread 'main' (107645) panicked at src/bin/fory_issue.rs:50:69:
   called `Result::unwrap()` on an `Err` value: TypeMismatch(4, 17)
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   ```
   
   Again can't de-serialize, but for a different reason? Not sure how that can 
happen?
   
   ```
   ./target/debug/fory_issue
   Serialize...
   Deserialize...
   
   thread 'main' (107646) panicked at src/bin/fory_issue.rs:50:69:
   called `Result::unwrap()` on an `Err` value: TypeMismatch(12, 17)
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   
   ```
   
   Appeared to succeed at de-serializing, but then can't get back what we put 
in?
   
   ```
   ./target/debug/fory_issue
   Serialize...
   Deserialize...
   
   thread 'main' (107647) panicked at src/bin/fory_issue.rs:52:68:
   called `Option::unwrap()` on a `None` value
   ```
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to