Skip to content

Commit e6ce332

Browse files
committed
I have no clue why it's segfaulting
1 parent 4ef8cad commit e6ce332

File tree

3 files changed

+47
-46
lines changed

3 files changed

+47
-46
lines changed

.github/workflows/continuous-integration.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
- os: macos-latest
125125
cc: ../llvm/bin/clang
126126
cxx: ../llvm/bin/clang++
127-
clangVer: "15.0"
127+
clangVer: "16.0"
128128
blas: off
129129
getBlas: off
130130
fftw: off
@@ -135,7 +135,7 @@ jobs:
135135
- os: macos-latest
136136
cc: ../llvm/bin/clang
137137
cxx: ../llvm/bin/clang++
138-
clangVer: "15.0"
138+
clangVer: "16.0"
139139
blas: on
140140
getBlas: off # Included with XCode
141141
fftw: on
@@ -186,7 +186,7 @@ jobs:
186186
- os: windows-latest
187187
cc: ../llvm/clang
188188
cxx: ../llvm/clang++
189-
clangVer: "15.0"
189+
clangVer: "16.0"
190190
blas: off
191191
getBlas: off
192192
fftw: off
@@ -197,7 +197,7 @@ jobs:
197197
- os: windows-latest
198198
cc: ../llvm/clang
199199
cxx: ../llvm/clang++
200-
clangVer: "15.0"
200+
clangVer: "16.0"
201201
blas: on
202202
getBlas: on
203203
fftw: on
@@ -208,7 +208,7 @@ jobs:
208208
- os: windows-latest
209209
cc: ./llvm/clang
210210
cxx: ./llvm/clang++
211-
clangVer: "15.0"
211+
clangVer: "16.0"
212212
blas: off
213213
getBlas: off
214214
fftw: off
@@ -219,7 +219,7 @@ jobs:
219219
- os: windows-latest
220220
cc: ./llvm/clang
221221
cxx: ./llvm/clang++
222-
clangVer: "15.0"
222+
clangVer: "16.0"
223223
blas: on
224224
getBlas: on
225225
fftw: on
@@ -454,14 +454,14 @@ jobs:
454454
- os: macos-latest
455455
cc: ../../llvm/bin/clang
456456
cxx: ../../llvm/bin/clang++
457-
clangVer: "15.0"
457+
clangVer: "16.0"
458458
smallArrays: ON
459459
pretty: "LibRapid_MacOS_Clang_OptimiseSmallArrays"
460460

461461
- os: macos-latest
462462
cc: ../../llvm/bin/clang
463463
cxx: ../../llvm/bin/clang++
464-
clangVer: "15.0"
464+
clangVer: "16.0"
465465
smallArrays: OFF
466466
pretty: "LibRapid_MacOS_Clang"
467467

@@ -480,14 +480,14 @@ jobs:
480480
- os: windows-latest
481481
cc: ../../llvm/clang
482482
cxx: ../../llvm/clang++
483-
clangVer: "15.0"
483+
clangVer: "16.0"
484484
smallArrays: ON
485485
pretty: "LibRapid_Windows_Clang_OptimiseSmallArrays"
486486

487487
- os: windows-latest
488488
cc: ../../llvm/clang
489489
cxx: ../../llvm/clang++
490-
clangVer: "15.0"
490+
clangVer: "16.0"
491491
smallArrays: OFF
492492
pretty: "LibRapid_Windows_Clang"
493493

librapid/include/librapid/array/arraySerialize.hpp

+33-31
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ namespace librapid::serialize {
2222

2323
DimType numDims = shape.ndim();
2424
size_t hashed = hasher();
25-
memcpy(serialized.data(), &numDims, sizeof(DimType));
26-
memcpy(serialized.data() + sizeof(DimType),
27-
shape.data().begin(),
28-
sizeof(SizeType) * LIBRAPID_MAX_ARRAY_DIMS);
29-
memcpy(serialized.data() + sizeof(DimType) + sizeof(SizeType) * LIBRAPID_MAX_ARRAY_DIMS,
30-
&hashed,
31-
sizeof(size_t));
25+
std::memcpy(serialized.data(), &numDims, sizeof(DimType));
26+
std::memcpy(serialized.data() + sizeof(DimType),
27+
shape.data().begin(),
28+
sizeof(SizeType) * LIBRAPID_MAX_ARRAY_DIMS);
29+
std::memcpy(serialized.data() + sizeof(DimType) +
30+
sizeof(SizeType) * LIBRAPID_MAX_ARRAY_DIMS,
31+
&hashed,
32+
sizeof(size_t));
3233
return serialized;
3334
}
3435

@@ -42,14 +43,14 @@ namespace librapid::serialize {
4243

4344
DimType numDims;
4445
size_t hashed;
45-
memcpy(&numDims, data.data(), sizeof(DimType));
46+
std::memcpy(&numDims, data.data(), sizeof(DimType));
4647
Shape shape = Shape::zeros(numDims);
47-
memcpy(shape.data().begin(),
48-
data.data() + sizeof(DimType),
49-
sizeof(SizeType) * LIBRAPID_MAX_ARRAY_DIMS);
50-
memcpy(&hashed,
51-
data.data() + sizeof(DimType) + sizeof(SizeType) * LIBRAPID_MAX_ARRAY_DIMS,
52-
sizeof(size_t));
48+
std::memcpy(shape.data().begin(),
49+
data.data() + sizeof(DimType),
50+
sizeof(SizeType) * LIBRAPID_MAX_ARRAY_DIMS);
51+
std::memcpy(&hashed,
52+
data.data() + sizeof(DimType) + sizeof(SizeType) * LIBRAPID_MAX_ARRAY_DIMS,
53+
sizeof(size_t));
5354

5455
LIBRAPID_ASSERT(
5556
hashed == hasher(),
@@ -77,12 +78,12 @@ namespace librapid::serialize {
7778

7879
size_t elements = storage.size();
7980
size_t hashed = hasher();
80-
memcpy(serialized.data(), &elements, sizeof(size_t));
81-
memcpy(
81+
std::memcpy(serialized.data(), &elements, sizeof(size_t));
82+
std::memcpy(
8283
serialized.data() + sizeof(size_t), storage.data(), sizeof(Scalar) * storage.size());
83-
memcpy(serialized.data() + sizeof(size_t) + sizeof(Scalar) * storage.size(),
84-
&hashed,
85-
sizeof(size_t));
84+
std::memcpy(serialized.data() + sizeof(size_t) + sizeof(Scalar) * storage.size(),
85+
&hashed,
86+
sizeof(size_t));
8687
return serialized;
8788
}
8889

@@ -94,12 +95,13 @@ namespace librapid::serialize {
9495

9596
size_t elements;
9697
size_t hashed;
97-
memcpy(&elements, data.data(), sizeof(size_t));
98+
std::memcpy(&elements, data.data(), sizeof(size_t));
9899
Storage<Scalar> storage(elements);
99-
memcpy(storage.data(), data.data() + sizeof(size_t), sizeof(Scalar) * storage.size());
100-
memcpy(&hashed,
101-
data.data() + sizeof(size_t) + sizeof(Scalar) * storage.size(),
102-
sizeof(size_t));
100+
std::memcpy(
101+
storage.data(), data.data() + sizeof(size_t), sizeof(Scalar) * storage.size());
102+
std::memcpy(&hashed,
103+
data.data() + sizeof(size_t) + sizeof(Scalar) * storage.size(),
104+
sizeof(size_t));
103105

104106
LIBRAPID_ASSERT(
105107
hashed == hasher(),
@@ -148,12 +150,12 @@ namespace librapid::serialize {
148150
std::vector<uint8_t> serialized;
149151
serialized.resize(shapeBytes + storageBytes);
150152

151-
memcpy(
153+
std::memcpy(
152154
serialized.data(), SerializerImpl<ShapeType>::serialize(shape).data(), shapeBytes);
153-
memcpy(serialized.data() + shapeBytes,
154-
SerializerImpl<StorageType>::serialize(storage).data(),
155-
storageBytes);
156-
memcpy(serialized.data() + shapeBytes + storageBytes, &hashed, sizeof(size_t));
155+
std::memcpy(serialized.data() + shapeBytes,
156+
SerializerImpl<StorageType>::serialize(storage).data(),
157+
storageBytes);
158+
std::memcpy(serialized.data() + shapeBytes + storageBytes, &hashed, sizeof(size_t));
157159

158160
return serialized;
159161
}
@@ -170,8 +172,8 @@ namespace librapid::serialize {
170172
data.begin() + SerializerImpl<ShapeType>::serialize(shape).size(), data.end()));
171173

172174
Type ret;
173-
ret.size_() = shape.size();
174-
ret.shape() = shape;
175+
ret.size_() = shape.size();
176+
ret.shape() = shape;
175177
ret.storage() = storage;
176178
return ret;
177179
}

librapid/include/librapid/utils/serialize.hpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ namespace librapid::serialize {
2727
std::vector<uint8_t> data;
2828
data.resize(sizeof(T) + sizeof(size_t));
2929
size_t hashed = hasher();
30-
memcpy(data.data() + sizeof(T), &hashed, sizeof(size_t));
31-
memcpy(data.data(), &obj, sizeof(T));
30+
std::memcpy(data.data() + sizeof(T), &hashed, sizeof(size_t));
31+
std::memcpy(data.data(), &obj, sizeof(T));
3232
return data;
3333
}
3434

3535
LIBRAPID_NODISCARD static T deserialize(const std::vector<uint8_t> &data) {
3636
size_t hashed;
37-
memcpy(&hashed, data.data() + sizeof(T), sizeof(size_t));
37+
std::memcpy(&hashed, data.data() + sizeof(T), sizeof(size_t));
3838
LIBRAPID_ASSERT(
3939
hasher() == hashed,
4040
"Hash mismatch. Ensure the types are the same and the data is not corrupted.");
4141

4242
T obj;
43-
memcpy(&obj, data.data(), sizeof(T));
43+
std::memcpy(&obj, data.data(), sizeof(T));
4444
return obj;
4545
}
4646
};
@@ -89,7 +89,6 @@ namespace librapid::serialize {
8989
return read(f);
9090
}
9191

92-
protected:
9392
private:
9493
std::vector<uint8_t> m_data;
9594
};

0 commit comments

Comments
 (0)