Remove abomonation support

Abomonation has numerous soundness problems which have been
well-documented in its issue tracker for over 2 years. Some of them
could be fixed, but some are fundamental to its design. If a user wants
super-fast ser/de, they should use rkyv.
This commit is contained in:
Ben Kimock 2022-02-05 17:05:59 -05:00
parent 7ade44dc1d
commit 698e130c3b
17 changed files with 2 additions and 323 deletions

View File

@ -61,13 +61,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: test
run: cargo test --features arbitrary,rand,serde-serialize,abomonation-serialize,sparse,debug,io,compare,libm,proptest-support,slow-tests;
run: cargo test --features arbitrary,rand,serde-serialize,sparse,debug,io,compare,libm,proptest-support,slow-tests;
test-nalgebra-glm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: test nalgebra-glm
run: cargo test -p nalgebra-glm --features arbitrary,serde-serialize,abomonation-serialize;
run: cargo test -p nalgebra-glm --features arbitrary,serde-serialize;
test-nalgebra-sparse:
runs-on: ubuntu-latest
steps:

View File

@ -53,7 +53,6 @@ convert-glam020 = [ "glam020" ]
## `serde-serialize`.
serde-serialize-no-std = [ "serde", "num-complex/serde" ]
serde-serialize = [ "serde-serialize-no-std", "serde/std" ]
abomonation-serialize = [ "abomonation" ]
rkyv-serialize-no-std = [ "rkyv" ]
rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std" ]
@ -81,7 +80,6 @@ alga = { version = "0.9", default-features = false, optional = true }
rand_distr = { version = "0.4", default-features = false, optional = true }
matrixmultiply = { version = "0.3", optional = true }
serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true }
abomonation = { version = "0.7", optional = true }
rkyv = { version = "~0.6.4", default-features = false, features = ["const_generics"], optional = true }
mint = { version = "0.5", optional = true }
quickcheck = { version = "1", optional = true }

View File

@ -21,7 +21,6 @@ default = [ "std" ]
std = [ "nalgebra/std", "simba/std" ]
arbitrary = [ "nalgebra/arbitrary" ]
serde-serialize = [ "nalgebra/serde-serialize-no-std" ]
abomonation-serialize = [ "nalgebra/abomonation-serialize" ]
cuda = [ "nalgebra/cuda" ]
# Conversion

View File

@ -1,7 +1,5 @@
use std::fmt::{self, Debug, Formatter};
// use std::hash::{Hash, Hasher};
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
use std::ops::Mul;
#[cfg(feature = "serde-serialize-no-std")]
@ -13,9 +11,6 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "serde-serialize-no-std")]
use std::marker::PhantomData;
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use crate::base::allocator::Allocator;
use crate::base::default_allocator::DefaultAllocator;
use crate::base::dimension::{Const, ToTypenum};
@ -282,32 +277,6 @@ unsafe impl<T: Scalar + Copy + bytemuck::Pod, const R: usize, const C: usize> by
{
}
#[cfg(feature = "abomonation-serialize")]
impl<T, const R: usize, const C: usize> Abomonation for ArrayStorage<T, R, C>
where
T: Scalar + Abomonation,
{
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
for element in self.as_slice() {
element.entomb(writer)?;
}
Ok(())
}
unsafe fn exhume<'a, 'b>(&'a mut self, mut bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
for element in self.as_mut_slice() {
let temp = bytes;
bytes = element.exhume(temp)?
}
Some(bytes)
}
fn extent(&self) -> usize {
self.as_slice().iter().fold(0, |acc, e| acc + e.extent())
}
}
#[cfg(feature = "rkyv-serialize-no-std")]
mod rkyv_impl {
use super::ArrayStorage;

View File

@ -1,6 +1,4 @@
use num::{One, Zero};
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
use approx::{AbsDiffEq, RelativeEq, UlpsEq};
use std::any::TypeId;
@ -13,9 +11,6 @@ use std::mem;
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, Field, SupersetOf};
use simba::simd::SimdPartialOrd;
@ -254,21 +249,6 @@ where
}
}
#[cfg(feature = "abomonation-serialize")]
impl<T: Scalar, R: Dim, C: Dim, S: Abomonation> Abomonation for Matrix<T, R, C, S> {
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.data.entomb(writer)
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.data.exhume(bytes)
}
fn extent(&self) -> usize {
self.data.extent()
}
}
#[cfg(feature = "compare")]
impl<T: Scalar, R: Dim, C: Dim, S: RawStorage<T, R, C>> matrixcompare_core::Matrix<T>
for Matrix<T, R, C, S>

View File

@ -1,14 +1,9 @@
use std::fmt;
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
use std::ops::Deref;
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use crate::allocator::Allocator;
use crate::base::DefaultAllocator;
use crate::storage::RawStorage;
@ -66,21 +61,6 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Unit<T> {
}
}
#[cfg(feature = "abomonation-serialize")]
impl<T: Abomonation> Abomonation for Unit<T> {
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.value.entomb(writer)
}
fn extent(&self) -> usize {
self.value.extent()
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.value.exhume(bytes)
}
}
#[cfg(feature = "rkyv-serialize-no-std")]
mod rkyv_impl {
use super::Unit;

View File

@ -1,6 +1,3 @@
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::vec::Vec;
@ -18,8 +15,6 @@ use serde::{
};
use crate::Storage;
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use std::mem::MaybeUninit;
/*
@ -402,21 +397,6 @@ where
}
}
#[cfg(feature = "abomonation-serialize")]
impl<T: Abomonation, R: Dim, C: Dim> Abomonation for VecStorage<T, R, C> {
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.data.entomb(writer)
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.data.exhume(bytes)
}
fn extent(&self) -> usize {
self.data.extent()
}
}
impl<T, R: Dim> Extend<T> for VecStorage<T, R, Dynamic> {
/// Extends the number of columns of the `VecStorage` with elements
/// from the given iterator.

View File

@ -1,15 +1,10 @@
use approx::{AbsDiffEq, RelativeEq, UlpsEq};
use std::fmt;
use std::hash;
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use simba::scalar::{RealField, SubsetOf};
use simba::simd::SimdRealField;
@ -81,29 +76,6 @@ pub struct Isometry<T, R, const D: usize> {
pub translation: Translation<T, D>,
}
#[cfg(feature = "abomonation-serialize")]
impl<T, R, const D: usize> Abomonation for Isometry<T, R, D>
where
T: SimdRealField,
R: Abomonation,
Translation<T, D>: Abomonation,
{
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.rotation.entomb(writer)?;
self.translation.entomb(writer)
}
fn extent(&self) -> usize {
self.rotation.extent() + self.translation.extent()
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.rotation
.exhume(bytes)
.and_then(|bytes| self.translation.exhume(bytes))
}
}
#[cfg(feature = "rkyv-serialize-no-std")]
mod rkyv_impl {
use super::Isometry;

View File

@ -3,15 +3,10 @@ use num::One;
use std::cmp::Ordering;
use std::fmt;
use std::hash;
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use simba::simd::SimdPartialOrd;
use crate::base::allocator::Allocator;
@ -130,26 +125,6 @@ where
}
}
#[cfg(feature = "abomonation-serialize")]
impl<T, D: DimName> Abomonation for OPoint<T, D>
where
T: Scalar,
OVector<T, D>: Abomonation,
DefaultAllocator: Allocator<T, D>,
{
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.coords.entomb(writer)
}
fn extent(&self) -> usize {
self.coords.extent()
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.coords.exhume(bytes)
}
}
impl<T: Scalar, D: DimName> OPoint<T, D>
where
DefaultAllocator: Allocator<T, D>,

View File

@ -2,17 +2,12 @@ use approx::{AbsDiffEq, RelativeEq, UlpsEq};
use num::Zero;
use std::fmt;
use std::hash::{Hash, Hasher};
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
#[cfg(feature = "serde-serialize-no-std")]
use crate::base::storage::Owned;
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use simba::scalar::{ClosedNeg, RealField};
use simba::simd::{SimdBool, SimdOption, SimdRealField};
@ -77,24 +72,6 @@ where
{
}
#[cfg(feature = "abomonation-serialize")]
impl<T: Scalar> Abomonation for Quaternion<T>
where
Vector4<T>: Abomonation,
{
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.coords.entomb(writer)
}
fn extent(&self) -> usize {
self.coords.extent()
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.coords.exhume(bytes)
}
}
#[cfg(feature = "serde-serialize-no-std")]
impl<T: Scalar> Serialize for Quaternion<T>
where

View File

@ -2,8 +2,6 @@ use approx::{AbsDiffEq, RelativeEq, UlpsEq};
use num::{One, Zero};
use std::fmt;
use std::hash;
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@ -11,9 +9,6 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "serde-serialize-no-std")]
use crate::base::storage::Owned;
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use simba::scalar::RealField;
use simba::simd::SimdRealField;
@ -94,25 +89,6 @@ where
{
}
#[cfg(feature = "abomonation-serialize")]
impl<T, const D: usize> Abomonation for Rotation<T, D>
where
T: Scalar,
SMatrix<T, D, D>: Abomonation,
{
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.matrix.entomb(writer)
}
fn extent(&self) -> usize {
self.matrix.extent()
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.matrix.exhume(bytes)
}
}
#[cfg(feature = "serde-serialize-no-std")]
impl<T: Scalar, const D: usize> Serialize for Rotation<T, D>
where

View File

@ -2,15 +2,10 @@ use approx::{AbsDiffEq, RelativeEq, UlpsEq};
use num::{One, Zero};
use std::fmt;
use std::hash;
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use crate::base::allocator::Allocator;
use crate::base::dimension::{DimNameAdd, DimNameSum, U1};
use crate::base::storage::Owned;
@ -64,25 +59,6 @@ where
{
}
#[cfg(feature = "abomonation-serialize")]
impl<T, const D: usize> Abomonation for Scale<T, D>
where
T: Scalar,
SVector<T, D>: Abomonation,
{
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.vector.entomb(writer)
}
fn extent(&self) -> usize {
self.vector.extent()
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.vector.exhume(bytes)
}
}
#[cfg(feature = "serde-serialize-no-std")]
impl<T: Scalar, const D: usize> Serialize for Scale<T, D>
where

View File

@ -3,15 +3,9 @@ use num::Zero;
use std::fmt;
use std::hash;
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use simba::scalar::{RealField, SubsetOf};
use simba::simd::SimdRealField;
@ -49,24 +43,6 @@ pub struct Similarity<T, R, const D: usize> {
scaling: T,
}
#[cfg(feature = "abomonation-serialize")]
impl<T: Scalar, R, const D: usize> Abomonation for Similarity<T, R, D>
where
Isometry<T, R, D>: Abomonation,
{
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.isometry.entomb(writer)
}
fn extent(&self) -> usize {
self.isometry.extent()
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.isometry.exhume(bytes)
}
}
impl<T: Scalar + hash::Hash, R: hash::Hash, const D: usize> hash::Hash for Similarity<T, R, D>
where
Owned<T, Const<D>>: hash::Hash,

View File

@ -2,15 +2,10 @@ use approx::{AbsDiffEq, RelativeEq, UlpsEq};
use num::{One, Zero};
use std::fmt;
use std::hash;
#[cfg(feature = "abomonation-serialize")]
use std::io::{Result as IOResult, Write};
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "abomonation-serialize")]
use abomonation::Abomonation;
use simba::scalar::{ClosedAdd, ClosedNeg, ClosedSub};
use crate::base::allocator::Allocator;
@ -64,25 +59,6 @@ where
{
}
#[cfg(feature = "abomonation-serialize")]
impl<T, const D: usize> Abomonation for Translation<T, D>
where
T: Scalar,
SVector<T, D>: Abomonation,
{
unsafe fn entomb<W: Write>(&self, writer: &mut W) -> IOResult<()> {
self.vector.entomb(writer)
}
fn extent(&self) -> usize {
self.vector.extent()
}
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
self.vector.exhume(bytes)
}
}
#[cfg(feature = "serde-serialize-no-std")]
impl<T: Scalar, const D: usize> Serialize for Translation<T, D>
where

View File

@ -1,51 +0,0 @@
use abomonation::{decode, encode, Abomonation};
use na::{
DMatrix, Isometry3, IsometryMatrix3, Matrix3x4, Point3, Quaternion, Rotation3, Similarity3,
SimilarityMatrix3, Translation3,
};
use rand::random;
#[test]
fn abomonate_dmatrix() {
assert_encode_and_decode(DMatrix::<f32>::new_random(3, 5));
}
macro_rules! test_abomonation(
($($test: ident, $ty: ty);* $(;)*) => {$(
#[test]
fn $test() {
assert_encode_and_decode(random::<$ty>());
}
)*}
);
test_abomonation! {
abomonate_matrix3x4, Matrix3x4<f32>;
abomonate_point3, Point3<f32>;
abomonate_translation3, Translation3<f64>;
abomonate_rotation3, Rotation3<f64>;
abomonate_isometry3, Isometry3<f32>;
abomonate_isometry_matrix3, IsometryMatrix3<f64>;
abomonate_similarity3, Similarity3<f32>;
abomonate_similarity_matrix3, SimilarityMatrix3<f32>;
abomonate_quaternion, Quaternion<f32>;
}
fn assert_encode_and_decode<T: Abomonation + PartialEq + Clone>(original_data: T) {
// Hold on to a clone for later comparison
let data = original_data.clone();
// Encode
let mut bytes = Vec::new();
unsafe {
let _ = encode(&original_data, &mut bytes);
}
// Drop the original, so that dangling pointers are revealed by the test
drop(original_data);
if let Some((result, rest)) = unsafe { decode::<T>(&mut bytes) } {
assert!(result == &data);
assert!(rest.len() == 0, "binary data was not decoded completely");
}
}

View File

@ -1,5 +1,3 @@
#[cfg(feature = "abomonation-serialize")]
mod abomonation;
mod blas;
mod cg;
mod conversion;

View File

@ -9,8 +9,6 @@ compile_error!(
Example: `cargo test --features debug,compare,rand,macros`"
);
#[cfg(feature = "abomonation-serialize")]
extern crate abomonation;
#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))]
#[macro_use]
extern crate approx;