Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UBSAN's cry afoul #1194

Merged
merged 1 commit into from
Mar 17, 2022
Merged

Fix UBSAN's cry afoul #1194

merged 1 commit into from
Mar 17, 2022

Conversation

KungFuJesus
Copy link
Contributor

Technically, we weren't actually doing this the way C wants us to,
legally. The zmemcpy's turn into NOPs for pretty much all > 0
optimization levels and this gets us defined behavior with the
sanitizer, putting the optimized load by arbitrary alignment into the
compiler's hands instead of ours.

Technically, we weren't actually doing this the way C wants us to,
legally.  The zmemcpy's turn into NOPs for pretty much all > 0
optimization levels and this gets us defined behavior with the
sanitizer, putting the optimized load by arbitrary alignment into the
compiler's hands instead of ours.
@codecov
Copy link

codecov bot commented Mar 17, 2022

Codecov Report

Merging #1194 (4184034) into develop (276a3ec) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff            @@
##           develop    #1194   +/-   ##
========================================
  Coverage    87.05%   87.06%           
========================================
  Files          113      113           
  Lines         9686     9692    +6     
  Branches      2462     2462           
========================================
+ Hits          8432     8438    +6     
- Misses        1008     1009    +1     
+ Partials       246      245    -1     
Flag Coverage Δ
macos_clang 26.66% <ø> (ø)
macos_gcc 70.26% <50.00%> (-0.02%) ⬇️
ubuntu_clang 85.06% <50.00%> (-0.04%) ⬇️
ubuntu_clang_debug 84.24% <50.00%> (-0.03%) ⬇️
ubuntu_clang_inflate_allow_invalid_dist 84.92% <50.00%> (+0.61%) ⬆️
ubuntu_clang_inflate_strict 85.00% <50.00%> (-0.03%) ⬇️
ubuntu_clang_mmap 85.12% <50.00%> (+0.60%) ⬆️
ubuntu_clang_pigz 39.74% <50.00%> (+0.01%) ⬆️
ubuntu_clang_pigz_no_optim 40.22% <ø> (ø)
ubuntu_clang_pigz_no_threads 39.33% <50.00%> (+0.01%) ⬆️
ubuntu_clang_reduced_mem 85.25% <50.00%> (-0.04%) ⬇️
ubuntu_gcc 72.27% <50.00%> (-0.03%) ⬇️
ubuntu_gcc_aarch64 71.87% <ø> (ø)
ubuntu_gcc_aarch64_compat_no_opt 69.14% <ø> (ø)
ubuntu_gcc_aarch64_no_acle 70.05% <ø> (ø)
ubuntu_gcc_aarch64_no_neon 70.01% <ø> (ø)
ubuntu_gcc_armhf 71.86% <ø> (ø)
ubuntu_gcc_armhf_compat_no_opt 69.01% <ø> (ø)
ubuntu_gcc_armhf_no_acle 71.87% <ø> (ø)
ubuntu_gcc_armhf_no_neon 71.79% <ø> (ø)
ubuntu_gcc_armsf 71.86% <ø> (ø)
ubuntu_gcc_armsf_compat_no_opt 69.01% <ø> (ø)
ubuntu_gcc_benchmark 73.83% <50.00%> (-0.03%) ⬇️
ubuntu_gcc_compat_no_opt 71.14% <ø> (ø)
ubuntu_gcc_compat_sprefix 73.18% <50.00%> (-0.03%) ⬇️
ubuntu_gcc_mingw_i686 0.00% <0.00%> (ø)
ubuntu_gcc_mingw_x86_64 0.00% <0.00%> (ø)
ubuntu_gcc_no_avx2 70.93% <100.00%> (+0.01%) ⬆️
ubuntu_gcc_no_ctz 73.05% <ø> (ø)
ubuntu_gcc_no_ctzll 72.82% <ø> (ø)
ubuntu_gcc_no_pclmulqdq 69.74% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_no_sse2 70.69% <100.00%> (+0.01%) ⬆️
ubuntu_gcc_no_sse4 70.57% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_o3 73.23% <50.00%> (ø)
ubuntu_gcc_osb ∅ <ø> (∅)
ubuntu_gcc_pigz 37.70% <50.00%> (-0.01%) ⬇️
ubuntu_gcc_pigz_aarch64 38.28% <ø> (ø)
ubuntu_gcc_ppc 72.62% <ø> (ø)
ubuntu_gcc_ppc64 73.40% <ø> (ø)
ubuntu_gcc_ppc64le 72.55% <ø> (ø)
ubuntu_gcc_ppc_no_power8 73.52% <ø> (ø)
ubuntu_gcc_s390x 73.54% <ø> (ø)
ubuntu_gcc_s390x_dfltcc 72.32% <ø> (ø)
ubuntu_gcc_s390x_dfltcc_compat 69.91% <ø> (ø)
ubuntu_gcc_s390x_no_crc32 73.29% <ø> (ø)
ubuntu_gcc_sparc64 73.41% <ø> (ø)
ubuntu_gcc_sprefix 73.00% <50.00%> (-0.03%) ⬇️
win64_gcc 72.17% <50.00%> (-0.03%) ⬇️
win64_gcc_compat_no_opt 71.84% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
arch/x86/chunkset_avx.c 100.00% <100.00%> (ø)
arch/x86/chunkset_sse2.c 44.44% <100.00%> (+11.11%) ⬆️
gzlib.c 69.33% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 276a3ec...4184034. Read the comment docs.

Copy link
Member

@nmoinvaz nmoinvaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only suggestion is to use a different variable name than tmp. At work we try to not name any variables temp.

Maybe call it set1 or broadcast or repeat..

Other than that it looks good.

@KungFuJesus
Copy link
Contributor Author

I was just going on the precedent set by the power8 and aarch64 ones that did the same thing.

@nmoinvaz
Copy link
Member

nmoinvaz commented Mar 17, 2022

Ah if they do the same then it can wait for another commit if we want to clean it all up later on. Anyways, I have already reviewed it and marked it approved. Good find.

Copy link
Member

@Dead2 Dead2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Dead2 Dead2 merged commit 1f87fac into zlib-ng:develop Mar 17, 2022
@Dead2 Dead2 mentioned this pull request Dec 27, 2022
Dead2 added a commit that referenced this pull request Mar 7, 2023
Changes since 2.0.6:
- Fix CVE-2022-37434 #1328
- Fix chunkmemset #1196
- Fix deflateBound too small #1236
- Fix Z_SOLO #1263
- Fix ACLE variant of crc32 #1274
- Fix inflateBack #1311
- Fix deflate_quick windowsize #1431
- Fix DFLTCC bugs related to adler32 #1349 and #1390
- Fix warnings #1194 #1312 #1362
- MacOS build fix #1198
- Add invalid windowBits handling #1293
- Support for Force TZCNT #1186
- Support for aligned_alloc() #1360
- Minideflate improvements #1175 #1238
- Dont use unaligned access for memcpy #1309
- Build system #1209 #1233 #1267 #1273 #1278 #1292 #1316 #1318 #1365
- Test improvements #1208 #1227 #1241 #1353
- Cleanup #1266
- Documentation #1205 #1359
- Misc improvements #1294 #1297 #1306 #1344 #1348
- Backported zlib fixes
- Backported CI workflows from Develop branch
Dead2 added a commit that referenced this pull request Mar 17, 2023
Changes since 2.0.6:
- Fix CVE-2022-37434 #1328
- Fix chunkmemset #1196
- Fix deflateBound too small #1236
- Fix Z_SOLO #1263
- Fix ACLE variant of crc32 #1274
- Fix inflateBack #1311
- Fix deflate_quick windowsize #1431
- Fix DFLTCC bugs related to adler32 #1349 and #1390
- Fix warnings #1194 #1312 #1362
- MacOS build fix #1198
- Add invalid windowBits handling #1293
- Support for Force TZCNT #1186
- Support for aligned_alloc() #1360
- Minideflate improvements #1175 #1238
- Dont use unaligned access for memcpy #1309
- Build system #1209 #1233 #1267 #1273 #1278 #1292 #1316 #1318 #1365
- Test improvements #1208 #1227 #1241 #1353
- Cleanup #1266
- Documentation #1205 #1359
- Misc improvements #1294 #1297 #1306 #1344 #1348
- Backported zlib fixes
- Backported CI workflows from Develop branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants