Page MenuHome GnuPG

Undefined behavior when running `make check` under Clang sanitizers
Closed, ResolvedPublic

Description

I accidentally closed T1877 when attempting to change its status from
Chatting to Unread. Refiling.

I believe the misaligned loads and the shifts are undefined behavior.

Intel's ICC compiler is ruthless about removing those statements. If analysis
improves for GCC, Clang and friends, then they could be removed by familiar
tools, too.

I believe the shifts are easy to fix - cast the 'int' to an 'unsigned int'
before the shift. That makes it legal C, and it removes the finding and
potential for removal by the compiler. Or you can do it in assembly, where that
particular C rule does not apply.

The misaligned loads are going to be trickier. I think the only legal/portable
way to do it is with a union. But they should be fixed to because there's a 200

  • 300 cycle performance penalty on some processors when the CPU has to fixup the

address.

The "/lib/x86_64-linux-gnu/libgpg-error.so.0: no version information available"
was covered under T1866. I'm not sure why it
present now since I used LD_LIBRARY_PATH.

And attached is the script I am using to acceptance test the suite. It requires
Clang 3.5 (Clang 3.5 recipe was provided with Bug 1872).


Running make check for libgcrypt-1.6.3


Making check in compat
make[1]: Entering directory
`/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/compat'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory
`/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/compat'
Making check in mpi
make[1]: Entering directory `/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/mpi'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/mpi'
Making check in cipher
make[1]: Entering directory
`/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/cipher'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory
`/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/cipher'
Making check in random
make[1]: Entering directory
`/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/random'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory
`/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/random'
Making check in src
make[1]: Entering directory `/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/src'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/src'
Making check in doc
make[1]: Entering directory `/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/doc'
make check-am
make[2]: Entering directory `/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/doc'
make[2]: Nothing to be done for `check-am'.
make[2]: Leaving directory `/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/doc'
make[1]: Leaving directory `/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/doc'
Making check in tests
make[1]: Entering directory
`/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/tests'
make check-TESTS
make[2]: Entering directory
`/home/gpg-user/gcrypt-2.0-sanitize/libgcrypt-1.6.3/tests'
./version: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./version)
version:1.6.3:
ciphers:arcfour:blowfish:cast5:des:aes:twofish:serpent:rfc2268:seed:camellia:idea:salsa20:gost28147:
pubkeys:dsa:elgamal:rsa:ecc:
digests:crc:gostr3411-94:md4:md5:rmd160:sha1:sha256:sha512:tiger:whirlpool:stribog:
rnd-mod:linux:
cpu-arch:x86:
mpi-asm:amd64/mpih-add1.S:amd64/mpih-sub1.S:amd64/mpih-mul1.S:amd64/mpih-mul2.S:amd64/mpih-mul3.S:amd64/mpih-lshift.S:amd64/mpih-rshift.S:
threads:pthread(weak):
hwflist:intel-cpu:intel-ssse3:intel-pclmul:intel-aesni:intel-avx:
fips-mode:n:n:
rng-type:standard:1:
PASS: version
./mpitests: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./mpitests)
FAIL: tsexp
./t-convert: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./t-convert)
PASS: t-convert
./t-mpi-bit: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./t-mpi-bit)
PASS: t-mpi-bit
./t-mpi-point: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./t-mpi-point)
PASS: t-mpi-point
./curves: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./curves)
PASS: curves
./t-lock: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./t-lock)
PASS: t-lock
./prime: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./prime)
PASS: prime
./basic: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./basic)
bufhelp.h:146:29: runtime error: load of misaligned address 0x7fff04fdd0e1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdd0e1: note: pointer points here
00 00 00 66 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61
72 34 33 46 4f 4f 42

^

bufhelp.h:192:7: runtime error: store to misaligned address 0x7fff04fdc7e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7e1: note: pointer points here
41 52 31 76 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 77 c8 fd 04 ff 7f
00 00 67 0e f4 00 00

^

bufhelp.h:146:5: runtime error: store to misaligned address 0x7fff04fdc881 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc881: note: pointer points here
00 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:191:15: runtime error: load of misaligned address 0x7fff04fdcc81 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc81: note: pointer points here
95 b9 7f d0 38 d0 22 2d 27 c0 b4 12 6b e8 af 06 1f 23 8e 99 00 00 00 00 00
00 00 00 00 00 00 00

^

bufhelp.h:192:36: runtime error: load of misaligned address 0x7fff04fdcc81 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc81: note: pointer points here
95 b9 7f d0 38 d0 22 2d 27 c0 b4 12 6b e8 af 06 1f 23 8e 99 00 00 00 00 00
00 00 00 00 00 00 00

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x7fff04fdd0e1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdd0e1: note: pointer points here
00 00 00 66 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61
72 34 33 46 4f 4f 42

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff04fdc3e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc3e1: note: pointer points here
2a 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:108:15: runtime error: load of misaligned address 0x7fff04fdd0e1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdd0e1: note: pointer points here
00 00 00 66 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61
72 34 33 46 4f 4f 42

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff04fdc881 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc881: note: pointer points here
00 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x7fff04fdc881 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdc881: note: pointer points here
00 00 00 66 ce f0 57 ef 47 b7 17 34 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x7fff04fdd4e1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdd4e1: note: pointer points here
41 52 31 76 66 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 d5 fd 04 ff 7f
00 00 90 d5 fd 04 ff

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff04fdc7e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7e1: note: pointer points here
41 52 31 76 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 77 c8 fd 04 ff 7f
00 00 67 0e f4 00 00

^

bufhelp.h:330:10: runtime error: load of misaligned address 0x7fff04fdd091 for
type 'const u32' (aka 'const unsigned int'), which requires 4 byte alignment
0x7fff04fdd091: note: pointer points here
04 04 04 30 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 2e 2c 3b 2f 5b
5d 7b 7d 2d 3d 41 42

^

bufhelp.h:341:3: runtime error: store to misaligned address 0x7fff04fdc3e1 for
type 'u32' (aka 'unsigned int'), which requires 4 byte alignment
0x7fff04fdc3e1: note: pointer points here
2a 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:192:7: runtime error: store to misaligned address 0x7fff04fdc3e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc3e1: note: pointer points here
2a 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:191:15: runtime error: load of misaligned address 0x7fff04fdc881 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdc881: note: pointer points here
00 00 00 66 5e e2 2b 9a d1 85 3d f2 b0 f1 2e fa 57 a2 e6 7f 7f 79 f8 69 4b
ed 8d e1 c3 bb 38 00

^

bufhelp.h:192:36: runtime error: load of misaligned address 0x7fff04fdc881 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdc881: note: pointer points here
00 00 00 66 5e e2 2b 9a d1 85 3d f2 b0 f1 2e fa 57 a2 e6 7f 7f 79 f8 69 4b
ed 8d e1 c3 bb 38 00

^

bufhelp.h:192:7: runtime error: store to misaligned address 0x7fff04fdc3e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc3e1: note: pointer points here
2a 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:191:15: runtime error: load of misaligned address 0x7fff04fdc881 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdc881: note: pointer points here
00 00 00 66 21 e3 57 50 ab d7 70 b0 54 42 a8 46 63 3e e6 07 03 2f b3 17 32
2c 03 29 39 79 bd 7d

^

bufhelp.h:108:15: runtime error: load of misaligned address 0x7fff04fdd0e1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdd0e1: note: pointer points here
01 00 00 66 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61
72 34 33 46 4f 4f 42

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff04fdc3e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc3e1: note: pointer points here
2a 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:330:10: runtime error: load of misaligned address 0x7fff04fdd091 for
type 'const u32' (aka 'const unsigned int'), which requires 4 byte alignment
0x7fff04fdd091: note: pointer points here
04 04 04 30 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 2e 2c 3b 2f 5b
5d 7b 7d 2d 3d 41 42

^

bufhelp.h:192:7: runtime error: store to misaligned address 0x7fff04fdc7e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7e1: note: pointer points here
41 52 31 76 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 77 c8 fd 04 ff 7f
00 00 67 0e f4 00 00

^

bufhelp.h:191:15: runtime error: load of misaligned address 0x7fff04fdcc81 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc81: note: pointer points here
83 73 e1 81 18 67 17 a5 57 5f 7f bb 21 c6 5b 70 78 88 2d 03 00 00 00 00 00
00 00 00 00 00 00 00

^

bufhelp.h:192:36: runtime error: load of misaligned address 0x7fff04fdcc81 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc81: note: pointer points here
83 73 e1 81 18 67 17 a5 57 5f 7f bb 21 c6 5b 70 78 88 2d 03 00 00 00 00 00
00 00 00 00 00 00 00

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x7fff04fdd4e1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdd4e1: note: pointer points here
41 52 31 76 66 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 d5 fd 04 ff 7f
00 00 90 d5 fd 04 ff

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff04fdc7e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7e1: note: pointer points here
41 52 31 76 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 77 c8 fd 04 ff 7f
00 00 67 0e f4 00 00

^

bufhelp.h:192:7: runtime error: store to misaligned address 0x7fff04fdc7d1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7d1: note: pointer points here
41 52 31 75 6f 6f 62 61 72 34 71 46 4f 4f 42 41 52 31 76 66 6f 6f 62 61 72
34 72 46 4f 4f 42 41

^

bufhelp.h:191:15: runtime error: load of misaligned address 0x7fff04fdcc71 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc71: note: pointer points here
1c 7d dc fe a1 3f 11 02 8a 5d 36 45 4f 67 2a 46 1a 53 30 3d a3 0c ab 58 37
7b a3 c8 d0 61 8b a3

^

bufhelp.h:192:36: runtime error: load of misaligned address 0x7fff04fdcc71 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc71: note: pointer points here
1c 7d dc fe a1 3f 11 02 8a 5d 36 45 4f 67 2a 46 1a 53 30 3d a3 0c ab 58 37
7b a3 c8 d0 61 8b a3

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x7fff04fdd4d1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdd4d1: note: pointer points here
41 52 31 75 66 6f 6f 62 61 72 34 71 46 4f 4f 42 41 52 31 76 66 6f 6f 62 61
72 34 72 46 4f 4f 42

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff04fdc7d1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7d1: note: pointer points here
41 52 31 75 6f 6f 62 61 72 34 71 46 4f 4f 42 41 52 31 76 66 6f 6f 62 61 72
34 72 46 4f 4f 42 41

^

bufhelp.h:335:10: runtime error: load of misaligned address 0x7fff04fdd091 for
type 'const u32' (aka 'const unsigned int'), which requires 4 byte alignment
0x7fff04fdd091: note: pointer points here
04 04 04 30 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 2e 2c 3b 2f 5b
5d 7b 7d 2d 3d 41 42

^

bufhelp.h:347:3: runtime error: store to misaligned address 0x7fff04fdc3e1 for
type 'u32' (aka 'unsigned int'), which requires 4 byte alignment
0x7fff04fdc3e1: note: pointer points here
2a 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:192:7: runtime error: store to misaligned address 0x7fff04fdc7e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7e1: note: pointer points here
41 52 31 76 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 77 c8 fd 04 ff 7f
00 00 67 0e f4 00 00

^

bufhelp.h:191:15: runtime error: load of misaligned address 0x7fff04fdcc81 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc81: note: pointer points here
1b 1a 74 2c bb 2c 70 b1 b8 41 1f 8b 83 8d b1 87 b9 9b 7f 03 00 00 00 00 00
00 00 00 00 00 00 00

^

bufhelp.h:192:36: runtime error: load of misaligned address 0x7fff04fdcc81 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc81: note: pointer points here
1b 1a 74 2c bb 2c 70 b1 b8 41 1f 8b 83 8d b1 87 b9 9b 7f 03 00 00 00 00 00
00 00 00 00 00 00 00

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x7fff04fdd4e1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdd4e1: note: pointer points here
41 52 31 76 66 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 d5 fd 04 ff 7f
00 00 90 d5 fd 04 ff

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff04fdc7e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7e1: note: pointer points here
41 52 31 76 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 77 c8 fd 04 ff 7f
00 00 67 0e f4 00 00

^

bufhelp.h:330:10: runtime error: load of misaligned address 0x7fff04fdd091 for
type 'const u32' (aka 'const unsigned int'), which requires 4 byte alignment
0x7fff04fdd091: note: pointer points here
04 04 04 30 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 2e 2c 3b 2f 5b
5d 7b 7d 2d 3d 41 42

^

bufhelp.h:341:3: runtime error: store to misaligned address 0x7fff04fdc3e1 for
type 'u32' (aka 'unsigned int'), which requires 4 byte alignment
0x7fff04fdc3e1: note: pointer points here
2a 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:330:10: runtime error: load of misaligned address 0x7fff04fdd0e1 for
type 'const u32' (aka 'const unsigned int'), which requires 4 byte alignment
0x7fff04fdd0e1: note: pointer points here
01 00 00 66 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61
72 34 33 46 4f 4f 42

^

bufhelp.h:341:3: runtime error: store to misaligned address 0x7fff04fdc3e1 for
type 'u32' (aka 'unsigned int'), which requires 4 byte alignment
0x7fff04fdc3e1: note: pointer points here
2a 00 00 66 6f 6f 62 61 72 34 32 46 4f 4f 42 41 52 31 37 66 6f 6f 62 61 72
34 33 46 4f 4f 42 41

^

bufhelp.h:192:7: runtime error: store to misaligned address 0x7fff04fdc7e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7e1: note: pointer points here
41 52 31 76 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 77 c8 fd 04 ff 7f
00 00 67 0e f4 00 00

^

bufhelp.h:191:15: runtime error: load of misaligned address 0x7fff04fdcc81 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc81: note: pointer points here
d3 bf d1 4b 92 c9 86 7d 25 f4 5c 06 a5 e5 87 2e 53 67 c5 77 00 00 00 00 00
00 00 00 00 00 00 00

^

bufhelp.h:192:36: runtime error: load of misaligned address 0x7fff04fdcc81 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdcc81: note: pointer points here
d3 bf d1 4b 92 c9 86 7d 25 f4 5c 06 a5 e5 87 2e 53 67 c5 77 00 00 00 00 00
00 00 00 00 00 00 00

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x7fff04fdd4e1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdd4e1: note: pointer points here
41 52 31 76 66 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 d5 fd 04 ff 7f
00 00 90 d5 fd 04 ff

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff04fdc7e1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdc7e1: note: pointer points here
41 52 31 76 6f 6f 62 61 72 34 72 46 4f 4f 42 41 52 31 77 77 c8 fd 04 ff 7f
00 00 67 0e f4 00 00

^

gost28147.c:408:19: runtime error: left shift of 152 by 24 places cannot be
represented in type 'int'
gost28147.c:404:19: runtime error: left shift of 158 by 24 places cannot be
represented in type 'int'
gost28147.c:348:19: runtime error: left shift of 218 by 24 places cannot be
represented in type 'int'
gost28147.c:352:19: runtime error: left shift of 134 by 24 places cannot be
represented in type 'int'
bufhelp.h:108:15: runtime error: load of misaligned address 0x7fff04fdb5a1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdb5a1: note: pointer points here
00 00 00 00 bf 8d de 8f e9 a4 e4 e2 87 f3 4c 57 24 a8 e8 10 28 43 f2 1d 6f
4a 2f ca 22 60 44 b1

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x7fff04fdb4e1 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff04fdb4e1: note: pointer points here
00 00 00 e3 be 8f dd 8b ec a2 e3 ea 8e f9 47 5b 29 a6 e7 00 39 51 e1 09 7a
5c 38 d2 3b 7a 5f ad

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff04fdb5a1 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff04fdb5a1: note: pointer points here
00 00 00 00 bf 8d de 8f e9 a4 e4 e2 87 f3 4c 57 24 a8 e8 10 28 43 f2 1d 6f
4a 2f ca 22 60 44 b1

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x61b00011c001 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x61b00011c001: note: pointer points here
fd ff 01 00 2b 7c 3c 67 73 51 63 18 a0 77 d7 fc 50 73 ae 0f 00 00 00 00 00
00 00 00 00 00 00 00

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x61b000131e34 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x61b000131e34: note: pointer points here

08 00 00 00 00 08 00 01  02 03 04 05 06 07 00 00  00 00 00 00 02 00 00 00  3a

2e 46 c8 ec 33 a5 48

^

cipher-ccm.c:280:7: runtime error: store to misaligned address 0x61b000131e34
for type 'volatile u64' (aka 'volatile unsigned long'), which requires 8 byte
alignment
0x61b000131e34: note: pointer points here

08 00 00 00 18 19 1a 1b  1c 1d 1e 00 00 00 00 00  00 00 00 00 00 00 00 00  00

00 00 00 00 00 00 00

^

bufhelp.h:341:3: runtime error: store to misaligned address 0x7fff04fdbf42 for
type 'u32' (aka 'unsigned int'), which requires 4 byte alignment
0x7fff04fdbf42: note: pointer points here
00 00 ff fe 11 12 13 14 15 16 17 18 19 00 00 02 00 00 d0 05 00 00 90 61 00
00 20 04 11 00 90 61

^

bufhelp.h:108:15: runtime error: load of misaligned address 0x61b0001b9f54 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x61b0001b9f54: note: pointer points here

00 00 00 00 58 e2 fc ce  fa 7e 30 61 36 7f 1d 57  a4 e7 45 5a 03 00 00 00  00

00 00 00 00 00 00 00

^

cipher-gcm.c:1144:7: runtime error: store to misaligned address 0x61b0001b9f54
for type 'volatile u64' (aka 'volatile unsigned long'), which requires 8 byte
alignment
0x61b0001b9f54: note: pointer points here

00 00 00 00 58 e2 fc ce  fa 7e 30 61 36 7f 1d 57  a4 e7 45 5a 03 00 00 00  00

00 00 00 00 00 00 00

^

cipher-gcm.c:1145:7: runtime error: store to misaligned address 0x61b0001b9f44
for type 'volatile u64' (aka 'volatile unsigned long'), which requires 8 byte
alignment
0x61b0001b9f44: note: pointer points here

00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00

00 00 00 00 00 00 00

^

cipher-gcm.c:1146:7: runtime error: store to misaligned address 0x61b0001b9f4c
for type 'volatile u64' (aka 'volatile unsigned long'), which requires 8 byte
alignment
0x61b0001b9f4c: note: pointer points here

00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00

00 00 00 03 00 00 00

^

gost28147.c:320:37: runtime error: left shift of 245 by 24 places cannot be
represented in type 'int'
bufhelp.h:108:26: runtime error: load of misaligned address 0x61b0001ee731 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x61b0001ee731: note: pointer points here
72 36 a8 de f7 dd ac 30 6a e2 66 cc f9 0b c1 1e e4 6d 51 3b 00 00 00 00 00
00 00 00 00 00 00 00

^

PASS: basic
./keygen: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./keygen)
PASS: keygen
./pubkey: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./pubkey)
PASS: pubkey
./hmac: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./hmac)
PASS: hmac
./hashtest: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./hashtest)
PASS: hashtest
./t-kdf: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./t-kdf)
PASS: t-kdf
./keygrip: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./keygrip)
PASS: keygrip
./fips186-dsa: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./fips186-dsa)
PASS: fips186-dsa
./aeswrap: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./aeswrap)
PASS: aeswrap
./pkcs1v2: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./pkcs1v2)
PASS: pkcs1v2
./random: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./random)
./random: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./random)
./random: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./random)
./random: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./random)
./random: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./random)
./random: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./random)
./random: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./random)
./random: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./random)
PASS: random
./dsa-rfc6979: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./dsa-rfc6979)
PASS: dsa-rfc6979
./t-ed25519: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./t-ed25519)

256 of 1026 tests done
512 of 1026 tests done
768 of 1026 tests done
1024 of 1026 tests done
1026 tests done

PASS: t-ed25519
./benchmark: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./benchmark)
Note: benchmark running in quick regression test mode.
bufhelp.h:335:10: runtime error: load of misaligned address 0x619000006997 for
type 'const u32' (aka 'const unsigned int'), which requires 4 byte alignment
0x619000006997: note: pointer points here
1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34
35 36 37 38 39 3a 3b

^

MD5 80ms 140ms 380ms 610ms 90ms
SHA1 0ms 40ms 270ms 40ms 0ms
bufhelp.h:335:10: runtime error: load of misaligned address 0x619000026797 for
type 'const u32' (aka 'const unsigned int'), which requires 4 byte alignment
0x619000026797: note: pointer points here
1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34
35 36 37 38 39 3a 3b

^

RIPEMD160 320ms 340ms 600ms 850ms 300ms
bufhelp.h:360:10: runtime error: load of misaligned address 0x7fff9d6a4d5c for
type 'const u64' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff9d6a4d5c: note: pointer points here

18 19 1a 1b 1c 1d 1e 1f  20 21 22 23 24 25 26 27  28 29 2a 2b 2c 2d 2e 2f  30

31 32 33 34 35 36 37

^

TIGER192 60ms 150ms 340ms 390ms 60ms
bufhelp.h:330:10: runtime error: load of misaligned address 0x619000036197 for
type 'const u32' (aka 'const unsigned int'), which requires 4 byte alignment
0x619000036197: note: pointer points here
1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34
35 36 37 38 39 3a 3b

^

SHA256 370ms 410ms 660ms 960ms 370ms
bufhelp.h:355:10: runtime error: load of misaligned address 0x61900006689f for
type 'const u64' (aka 'const unsigned long'), which requires 8 byte alignment
0x61900006689f: note: pointer points here
24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c
3d 3e 3f 40 41 42 43

^

SHA384 220ms 250ms 490ms 520ms 220ms
SHA512 220ms 250ms 480ms 490ms 220ms
SHA224 360ms 410ms 640ms 850ms 370ms
bufhelp.h:335:10: runtime error: load of misaligned address 0x6190000c6c97 for
type 'const u32' (aka 'const unsigned int'), which requires 4 byte alignment
0x6190000c6c97: note: pointer points here
1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34
35 36 37 38 39 3a 3b

^

MD4 50ms 80ms 330ms 540ms 50ms
CRC32 20ms 20ms 190ms 60ms 30ms
CRC32RFC1510 20ms 20ms 200ms 60ms 20ms
CRC24RFC2440 210ms 220ms 370ms 260ms 210ms
bufhelp.h:355:10: runtime error: load of misaligned address 0x7fff9d6a4d5c for
type 'const u64' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff9d6a4d5c: note: pointer points here

18 19 1a 1b 1c 1d 1e 1f  20 21 22 23 24 25 26 27  28 29 2a 2b 2c 2d 2e 2f  30

31 32 33 34 35 36 37

^

WHIRLPOOL 650ms 770ms 970ms 930ms 640ms
TIGER 60ms 140ms 330ms 360ms 60ms
TIGER2 60ms 120ms 340ms 400ms 50ms
gost28147.c:320:37: runtime error: left shift of 239 by 24 places cannot be
represented in type 'int'
gost28147.c:352:19: runtime error: left shift of 166 by 24 places cannot be
represented in type 'int'
gost28147.c:348:19: runtime error: left shift of 237 by 24 places cannot be
represented in type 'int'
GOSTR3411_94 1610ms 1610ms 1890ms 1620ms 1610ms
bufhelp.h:360:10: runtime error: load of misaligned address 0x7fff9d6a4d5c for
type 'const u64' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff9d6a4d5c: note: pointer points here

18 19 1a 1b 1c 1d 1e 1f  20 21 22 23 24 25 26 27  28 29 2a 2b 2c 2d 2e 2f  30

31 32 33 34 35 36 37

^

STRIBOG256 1080ms 1150ms 1360ms 1260ms 1090ms
STRIBOG512 1080ms 1160ms 1370ms 1290ms 1090ms

HMAC_SHA256 370ms 410ms 470ms
HMAC_SHA224 370ms 410ms 470ms
HMAC_SHA512 210ms 260ms 290ms
HMAC_SHA384 210ms 260ms 290ms
HMAC_SHA1 10ms 30ms 80ms
HMAC_MD5 90ms 140ms 190ms
HMAC_MD4 50ms 90ms 140ms
HMAC_RIPEMD160 300ms 350ms 390ms
HMAC_TIGER 60ms 100ms 150ms
HMAC_WHIRLPOOL 640ms 670ms 740ms
HMAC_GOSTR3411_94 1600ms 1620ms 1700ms
HMAC_STRIBOG256 1090ms 1130ms 1190ms
HMAC_STRIBOG512 1090ms 1130ms 1180ms
bufhelp.h:108:26: runtime error: load of misaligned address 0x61b00001f221 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x61b00001f221: note: pointer points here
00 00 00 00 9c a4 43 89 eb 75 1d ec 5b 26 9c bd bb 0d 49 2e 39 48 87 13 d6
ea 3b d8 b6 4d 39 7b

^

CMAC_AES 0ms 20ms 80ms
CMAC_3DES 2010ms 2040ms 2260ms
CMAC_CAMELLIA 560ms 590ms 710ms
CMAC_CAST5 20ms 40ms 110ms
CMAC_BLOWFISH 30ms 30ms 100ms
CMAC_TWOFISH 20ms 30ms 90ms
CMAC_SERPENT 3530ms 3550ms 3710ms
CMAC_SEED 650ms 680ms 780ms
CMAC_RFC2268 330ms 340ms 510ms
CMAC_IDEA 480ms 510ms 670ms
CMAC_GOST28147 280ms 300ms 440ms
bufhelp.h:108:15: runtime error: load of misaligned address 0x61b00001e454 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x61b00001e454: note: pointer points here

00 00 00 00 4b 99 9d 4a  3b 60 83 fb 45 45 4b 4e  7f 2a 27 de 03 00 00 00  00

00 00 00 00 00 00 00

^

cipher-gcm.c:1144:7: runtime error: store to misaligned address 0x61b00001e454
for type 'volatile u64' (aka 'volatile unsigned long'), which requires 8 byte
alignment
0x61b00001e454: note: pointer points here

00 00 00 00 4b 99 9d 4a  3b 60 83 fb 45 45 4b 4e  7f 2a 27 de 03 00 00 00  00

00 00 00 00 00 00 00

^

cipher-gcm.c:1145:7: runtime error: store to misaligned address 0x61b00001e444
for type 'volatile u64' (aka 'volatile unsigned long'), which requires 8 byte
alignment
0x61b00001e444: note: pointer points here

00 00 00 00 40 42 0f 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00

00 00 00 00 00 00 00

^

cipher-gcm.c:1146:7: runtime error: store to misaligned address 0x61b00001e44c
for type 'volatile u64' (aka 'volatile unsigned long'), which requires 8 byte
alignment
0x61b00001e44c: note: pointer points here

00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00

00 00 00 03 00 00 00

^

GMAC_AES 0ms 0ms 70ms
GMAC_CAMELLIA 0ms 0ms 80ms
GMAC_TWOFISH 0ms 0ms 70ms
GMAC_SERPENT 0ms 0ms 80ms
GMAC_SEED 0ms 0ms 80ms

             ECB/Stream         CBC             CFB             OFB         
CTR             CCM             GCM
          --------------- --------------- --------------- ---------------

IDEA 440ms 450ms 480ms 490ms 490ms 510ms 480ms 480ms
490ms 500ms - - - -
3DES 2030ms 2010ms 2040ms 2050ms 2050ms 2070ms 2060ms 2050ms
2040ms 2060ms - - - -
CAST5 0ms 30ms 30ms 0ms 30ms 0ms 30ms 20ms
0ms 0ms - - - -
BLOWFISH 30ms 0ms 40ms 0ms 30ms 0ms 30ms 20ms
0ms 0ms - - - -
cipher-ccm.c:280:7: runtime error: store to misaligned address 0x61b000019034
for type 'volatile u64' (aka 'volatile unsigned long'), which requires 8 byte
alignment
0x61b000019034: note: pointer points here

08 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00

00 00 00 00 00 00 00

^

AES 0ms 20ms 0ms 0ms 0ms 0ms 20ms 0ms
0ms 0ms 40ms 10ms 0ms 0ms
AES192 20ms 0ms 10ms 0ms 0ms 0ms 20ms 10ms
0ms 0ms 20ms 10ms 10ms 0ms
AES256 10ms 0ms 10ms 0ms 0ms 0ms 20ms 10ms
0ms 0ms 20ms 20ms 0ms 10ms
TWOFISH 0ms 10ms 20ms 0ms 20ms 0ms 20ms 10ms
10ms 0ms 40ms 30ms 10ms 0ms
ARCFOUR 70ms 70ms
DES 640ms 640ms 660ms 670ms 670ms 660ms 670ms 660ms
670ms 680ms - - - -
TWOFISH128 0ms 10ms 20ms 0ms 20ms 0ms 20ms 10ms
10ms 0ms 30ms 40ms 0ms 10ms
SERPENT128 3610ms 3640ms 3640ms 0ms 3630ms 10ms 3640ms 3610ms
0ms 10ms 3810ms 3820ms 0ms 10ms
SERPENT192 3600ms 3630ms 3610ms 10ms 3610ms 0ms 3620ms 3600ms
10ms 0ms 3790ms 3790ms 0ms 10ms
SERPENT256 3600ms 3610ms 3620ms 0ms 3610ms 10ms 3610ms 3660ms
0ms 10ms 3890ms 3820ms 10ms 0ms
RFC2268_40 330ms 340ms 330ms 360ms 320ms 340ms 330ms 330ms
330ms 330ms - - - -
RFC2268_128 320ms 340ms 330ms 360ms 330ms 340ms 330ms 340ms
340ms 330ms - - - -
SEED 660ms 660ms 680ms 680ms 680ms 670ms 670ms 680ms
660ms 660ms 1530ms 1520ms 680ms 670ms
CAMELLIA128 570ms 600ms 570ms 0ms 590ms 10ms 570ms 580ms
0ms 10ms 670ms 670ms 0ms 10ms
CAMELLIA192 800ms 780ms 780ms 0ms 780ms 0ms 790ms 790ms
0ms 10ms 920ms 910ms 10ms 10ms
CAMELLIA256 800ms 760ms 760ms 10ms 790ms 0ms 790ms 790ms
0ms 10ms 930ms 910ms 0ms 0ms
bufhelp.h:108:15: runtime error: load of misaligned address 0x7fff9d6a4021 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff9d6a4021: note: pointer points here
00 00 00 00 bf 8d de 8f e9 a4 e4 e2 87 f3 4c 57 24 a8 e8 10 28 43 f2 1d 6f
4a 2f ca 22 60 44 b1

^

bufhelp.h:108:26: runtime error: load of misaligned address 0x7fff9d6a3f61 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x7fff9d6a3f61: note: pointer points here
00 00 00 e3 be 8f dd 8b ec a2 e3 ea 8e f9 47 5b 29 a6 e7 00 39 51 e1 09 7a
5c 38 d2 3b 7a 5f ad

^

bufhelp.h:108:5: runtime error: store to misaligned address 0x7fff9d6a4021 for
type 'uintptr_t' (aka 'unsigned long'), which requires 8 byte alignment
0x7fff9d6a4021: note: pointer points here
00 00 00 00 bf 8d de 8f e9 a4 e4 e2 87 f3 4c 57 24 a8 e8 10 28 43 f2 1d 6f
4a 2f ca 22 60 44 b1

^

SALSA20 0ms 0ms
SALSA20R12 0ms 10ms
GOST28147 270ms 270ms 290ms 280ms 290ms 290ms 290ms 280ms
290ms 290ms - - - -

Algorithm generate 10*sign 10*verify

RSA 1024 bit 60ms 30ms 10ms
RSA 2048 bit 2510ms 170ms 0ms
RSA 3072 bit 2720ms 370ms 10ms
RSA 4096 bit 17200ms 790ms 0ms
DSA 1024/160 - 60ms 30ms
DSA 2048/224 - 80ms 80ms
DSA 3072/256 - 120ms 120ms
ECDSA 192 bit 100ms 220ms 370ms
ECDSA 224 bit 120ms 300ms 550ms
ECDSA 256 bit 110ms 280ms 480ms
ECDSA 384 bit 180ms 420ms 830ms
ECDSA 521 bit 340ms 810ms 1440ms
EdDSA Ed25519 40ms 540ms 780ms
GOST 256 bit 110ms 320ms 490ms
GOST 512 bit 300ms 770ms 1380ms

powm 20ms 40ms 110ms

random 240ms 230ms
PASS: benchmark
./bench-slope: /lib/x86_64-linux-gnu/libgpg-error.so.0: no version information
available (required by ./bench-slope)
gost28147.c:320:37: runtime error: left shift of 173 by 24 places cannot be
represented in type 'int'
gost28147.c:348:19: runtime error: left shift of 212 by 24 places cannot be
represented in type 'int'
gost28147.c:352:19: runtime error: left shift of 226 by 24 places cannot be
represented in type 'int'
bufhelp.h:108:26: runtime error: load of misaligned address 0x61b00001f221 for
type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x61b00001f221: note: pointer points here
00 00 00 00 1f 35 44 da 5a b1 fa f8 0c 76 65 d0 09 bc 6a 0a 3e 6a 89 b4 b5
63 f5 f0 18 ec cb a0
...

Details

Version
1.6.3

Event Timeline

JW set Version to 1.6.3.
JW added a subscriber: JW.

Added updated buf.help.h that removes the undefined behavior.

Added updated gost28147.c that removes the undefined behavior.

Attached is the script I am using to acceptance test the suite. It requires
Clang 3.5 (Clang 3.5 recipe was provided with Bug 1872).

The following still harbors undefined behavior, but I did not want to touch it
due to fears of breaking the zeoizer:

cipher-gcm.c:1144:7: runtime error: store to misaligned address...
cipher-gcm.c:1145:7: runtime error: store to misaligned address...
cipher-gcm.c:1146:7: runtime error: store to misaligned address...

wipememory (c->u_mode.gcm.tagiv, GCRY_GCM_BLOCK_LEN);  // Line 1144
wipememory (c->u_mode.gcm.aadlen, sizeof (c->u_mode.gcm.aadlen)); // Line 1145
wipememory (c->u_mode.gcm.datalen, sizeof (c->u_mode.gcm.datalen)); //

Line 1146

cipher-ccm.c:280:7: runtime error: store to misaligned address...

wipememory (c->u_mode.ccm.macbuf, 16);  // Line 280

Also see "Is a misaligned load due to a cast undefined behavior?"
(http://stackoverflow.com/q/28893303) on Stack Overflow.

I wanted to verify it was in fact undefined behavior.

Changed status to 'unread'. I am not chatting.

Unaligned memory accesses are enabled on only architectures that can handle
those. The buf_xor function that you copy-pasted partially to stackoverflow
actually has alignment checks:

#if defined(i386) || defined(x86_64) || \

defined(__powerpc__) || defined(__powerpc64__) || \
(defined(__arm__) && defined(__ARM_FEATURE_UNALIGNED)) || \
defined(__aarch64__)

/* These architectures are able of unaligned memory accesses and can

  handle those fast.
*/
  1. define BUFHELP_FAST_UNALIGNED_ACCESS 1 #endif ... /* Optimized function for buffer xoring */ static inline void buf_xor(void *_dst, const void *_src1, const void *_src2, size_t len) { byte *dst = _dst; const byte *src1 = _src1; const byte *src2 = _src2; uintptr_t *ldst; const uintptr_t *lsrc1, *lsrc2; #ifndef BUFHELP_FAST_UNALIGNED_ACCESS const unsigned int longmask = sizeof(uintptr_t) - 1; /* Skip fast processing if buffers are unaligned. */ if (((uintptr_t)dst | (uintptr_t)src1 | (uintptr_t)src2) & longmask) goto do_bytes; #endif ldst = (uintptr_t *)(void *)dst; lsrc1 = (const uintptr_t *)(const void *)src1; lsrc2 = (const uintptr_t *)(const void *)src2; for (; len >= sizeof(uintptr_t); len -= sizeof(uintptr_t)) *ldst++ = *lsrc1++ ^ *lsrc2++; dst = (byte *)ldst; src1 = (const byte *)lsrc1; src2 = (const byte *)lsrc2; #ifndef BUFHELP_FAST_UNALIGNED_ACCESS do_bytes: #endif /* Handle tail. */ for (; len; len--) *dst++ = *src1++ ^ *src2++; }

So, yes, we use unaligned memory accesses but only when it is known that they work.

Now, solution (with same code generation, without undefined behaviour) to this
issue is to tell the compiler that we really want to do unaligned accesses. For
that we need to change the accesses to happen through type that has proper
one-byte alignment, but generates the same code (unaligned word-size memory
accesses) on the few architectures that enable 'BUFHELP_FAST_UNALIGNED_ACCESS':

#ifdef BUFHELP_FAST_UNALIGNED_ACCESS
/* Define type with one-byte alignment on architectures with fast unaligned

  memory accesses.
*/

typedef struct bufhelp_int_s
{

uintptr_t a;

} attribute((packed, aligned(1))) bufhelp_int_t;
#else
/* Define type with default alignment for other architectures (unaligned

  accessed handled in per byte loops).
*/

typedef struct bufhelp_int_s
{

uintptr_t a;

} bufhelp_int_t;
#endif

Ofcourse, BUFHELP_FAST_UNALIGNED_ACCESS now need to be limited to compiler that
support GCC style attributes.

FWIW: libgpg-error.so.0: no version information available"
is a harmless diagnostic issued for example by Debian to help detecting broken
ABIs. It is a non-issue here. We can't do anthing about it. With some
libgpg-error we introduced symbol versioning to assist the loader and to hide
internal symbols from other ELF objects.

Jussi: Do we consider this as no-bug?