Skip to content

Commit f789847

Browse files
committed
Merge commit '4a0574db63dec8ab4efd9f8525bf1b22baefdfcd' into update-c-blsoc2
2 parents ae42c21 + 4a0574d commit f789847

File tree

12 files changed

+52
-27
lines changed

12 files changed

+52
-27
lines changed

src/c-blosc2/.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: FrancescAlted

src/c-blosc2/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ cmake-build-*
66
/blosc/config.h
77
/doc/doxygen/xml/
88
/doc/xml
9+
.vs/

src/c-blosc2/ANNOUNCE.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
# Announcing C-Blosc2 2.17.0
1+
# Announcing C-Blosc2 2.17.1
22
A fast, compressed and persistent binary data store library for C.
33

44
## What is new?
55

6-
This introduces some new features and improvements:
6+
Several fixes affecting uninitialized memory access and others:
77

8-
* New b2nd_copy_buffer2() function for copying buffers with typesizes
9-
larger than 255. The previous b2nd_copy_buffer() function is now
10-
deprecated and will be removed in a future release.
8+
* Fix uninitialized memory access in newly added unshuffle12_sse2 and unshuffle12_avx2 functions
9+
* Fix unaligned access in _sw32 and sw32_
10+
* Fix DWORD being printed as %s in sprintf call
11+
* Fix warning on unused variable (since this variable was only being used in the linux branch)
12+
* `splitmode` variable was uninitialized if goto was triggered
1113

12-
* Support repeated values larger than 8-bit, also for n-dim arrays.
13-
This is useful for compressing arrays with large runs of repeated
14-
values, like in the case of images with large areas of the same color.
14+
See PR #658. Many thanks to @EmilDohne for this nice job.
1515

16-
* Fix a leak in the pthreads emulation for Windows. Fixes #647.
17-
Thanks to @jocbeh for the report and fix (#655).
18-
19-
* Update zstd to 1.5.7. Thanks to Tom Birch.
20-
21-
For more info, please see the release notes in:
16+
For more info, see the release notes in:
2217

2318
https://github.com/Blosc/c-blosc2/blob/main/RELEASE_NOTES.md
2419

src/c-blosc2/RELEASE_NOTES.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Release notes for C-Blosc2
22
==========================
33

4+
Changes from 2.17.0 to 2.17.1
5+
=============================
6+
7+
Several fixes affecting uninitialized memory access and others:
8+
9+
* Fix uninitialized memory access in newly added unshuffle12_sse2 and unshuffle12_avx2 functions
10+
* Fix unaligned access in _sw32 and sw32_
11+
* Fix DWORD being printed as %s in sprintf call
12+
* Fix warning on unused variable (since this variable was only being used in the linux branch)
13+
* `splitmode` variable was uninitialized if goto was triggered
14+
15+
See PR #658. Many thanks to @EmilDohne for this nice job.
16+
17+
418
Changes from 2.16.0 to 2.17.0
519
=============================
620

src/c-blosc2/blosc/blosc-private.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static inline int32_t sw32_(const void* pa) {
9191

9292
bool little_endian = is_little_endian();
9393
if (little_endian) {
94-
idest = *(int32_t *)pa;
94+
memcpy(&idest, pa, sizeof(idest));
9595
}
9696
else {
9797
#if defined (__GNUC__)
@@ -116,7 +116,7 @@ static inline void _sw32(void* dest, int32_t a) {
116116

117117
bool little_endian = is_little_endian();
118118
if (little_endian) {
119-
*(int32_t *)dest_ = a;
119+
memcpy(dest_, &a, sizeof(a));;
120120
}
121121
else {
122122
#if defined (__GNUC__)
@@ -280,7 +280,7 @@ static inline void* load_lib(char *plugin_name, char *libpath) {
280280
return loaded_lib;
281281
} else {
282282
#if defined(_WIN32)
283-
BLOSC_TRACE_INFO("Failed to load %s directly, error: %s\n", libpath, GetLastError());
283+
BLOSC_TRACE_INFO("Failed to load %s directly, error: %lu\n", libpath, GetLastError());
284284
#else
285285
BLOSC_TRACE_INFO("Failed to load %s directly, error: %s\n", libpath, dlerror());
286286
#endif

src/c-blosc2/blosc/blosc2-stdio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,11 @@ int64_t blosc2_stdio_mmap_write(const void *ptr, int64_t size, int64_t nitems, i
376376
}
377377

378378
if (mmap_file->mapping_size < mmap_file->file_size) {
379-
int64_t old_mapping_size = mmap_file->mapping_size;
380379
mmap_file->mapping_size = mmap_file->file_size * 2;
381380

382381
#if defined(__linux__)
382+
int64_t old_mapping_size = mmap_file->mapping_size;
383+
383384
/* mremap is the best option as it also ensures that the old data is still available in c mode. Unfortunately, it
384385
is no POSIX standard and only available on Linux */
385386
char* new_address = mremap(mmap_file->addr, old_mapping_size, mmap_file->mapping_size, MREMAP_MAYMOVE);

src/c-blosc2/blosc/directories.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ int blosc2_remove_dir(const char* dir_path) {
102102
char* fname;
103103
while ((de = readdir(dr)) != NULL) {
104104
fname = malloc(strlen(path) + strlen(de->d_name) + 1);
105-
sprintf(fname, "%s%s", path, de->d_name);
105+
if (path != NULL) {
106+
sprintf(fname, "%s%s", path, de->d_name);
107+
}
108+
else {
109+
sprintf(fname, "%s", de->d_name);
110+
}
106111
if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) {
107112
free(fname);
108113
continue;

src/c-blosc2/blosc/frame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,8 +3186,8 @@ void* frame_update_chunk(blosc2_frame_s* frame, int64_t nchunk, void* chunk, blo
31863186
return NULL;
31873187
}
31883188
}
3189-
int32_t cbytes_old;
3190-
int64_t old_offset;
3189+
int32_t cbytes_old = 0;
3190+
int64_t old_offset = 0;
31913191
if (!frame->sframe) {
31923192
// See how big would be the space
31933193
old_offset = offsets[nchunk];

src/c-blosc2/blosc/shuffle-avx2.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,15 @@ unshuffle12_avx2(uint8_t* const dest, const uint8_t* const src,
540540
__m256i store_mask = _mm256_set_epi32(0x0, 0x0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
541541
int32_t jump = 2*bytesoftype;
542542
for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
543-
/* Fetch 32 elements (512 bytes) into 16 YMM registers. */
543+
/* Fetch 24 elements (384 bytes) into 12 YMM registers. */
544544
const uint8_t* const src_for_ith_element = src + i;
545545
for (j = 0; j < bytesoftype; j++) {
546546
ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
547547
}
548+
/* Initialize the last 4 registers (128 bytes) to null */
549+
for (j = bytesoftype; j < 16; j++) {
550+
ymm0[j] = _mm256_setzero_si256();
551+
}
548552

549553
/* Shuffle bytes */
550554
for (j = 0; j < 8; j++) {

src/c-blosc2/blosc/shuffle-sse2.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,15 @@ unshuffle12_sse2(uint8_t* const dest, const uint8_t* const src,
379379
__m128i mask = _mm_set_epi8( 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
380380

381381
for (i = 0; i < vectorizable_elements; i += sizeof(__m128i)) {
382-
/* Load 16 elements (256 bytes) into 16 XMM registers. */
382+
/* Load 12 elements (192 bytes) into 12 XMM registers. */
383383
const uint8_t* const src_for_ith_element = src + i;
384384
for (j = 0; j < bytesoftype; j++) {
385385
xmm1[j] = _mm_loadu_si128((__m128i*)(src_for_ith_element + (j * total_elements)));
386386
}
387+
/* Initialize the last 4 registers (64 bytes) to null */
388+
for (j = bytesoftype; j < 16; j++) {
389+
xmm1[j] = _mm_setzero_si128();
390+
}
387391
/* Shuffle bytes */
388392
for (j = 0; j < 8; j++) {
389393
/* Compute the low 32 bytes */

0 commit comments

Comments
 (0)