[gnutls-devel] libtasn1 | Reading CHOICE name confuses valgrind (#9)
Development of GNU's TLS library
gnutls-devel at lists.gnutls.org
Wed Oct 30 10:39:51 CET 2019
Tim Rühsen commented:
Valgrind doens't complain when built with -O0, the assembler (L122/strcmp starts at the arrow):
```
0x00005555555554f8 <+803>: mov $0x76,%esi
0x00005555555554fd <+808>: lea 0xb14(%rip),%rdi # 0x555555556018
0x0000555555555504 <+815>: mov $0x0,%eax
0x0000555555555509 <+820>: callq 0x555555555060 <printf at plt>
0x000055555555550e <+825>: mov $0x1,%edi
0x0000555555555513 <+830>: callq 0x5555555550b0 <exit at plt>
=> 0x0000555555555518 <+835>: lea -0x4b0(%rbp),%rax
0x000055555555551f <+842>: lea 0xb4c(%rip),%rsi # 0x555555556072
0x0000555555555526 <+849>: mov %rax,%rdi
0x0000555555555529 <+852>: callq 0x555555555080 <strcmp at plt>
0x000055555555552e <+857>: test %eax,%eax
0x0000555555555530 <+859>: jne 0x555555555552 <main+893>
0x0000555555555532 <+861>: mov $0x7c,%esi
0x0000555555555537 <+866>: lea 0xada(%rip),%rdi # 0x555555556018
```
In comparison, the code generated by gcc 9 with -O2 (see above) just accesses 16 bytes of stack memory for an optimized version of `strcmp`. So no wonder that valgrind complains, though it is a false positive.
To calm down valgrind, we can `*data = 0` before `asn1_read_value()`. This just 'marks' `data` as being initialized. Alternatively, we have to add/create a valgrind suppression.
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/libtasn1/issues/9#note_237741131
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20191030/b80691c9/attachment.html>
More information about the Gnutls-devel
mailing list