Ok, I have actually found out, that I get the access violation error, regardless of what I return. So its not so much an error with passing that unserialized object, but when the function returns (regardless of what it returns), if read has been called, it will crash,