Summary: | Add replacements for wmemchr and wcsnlen on Linux | ||
---|---|---|---|
Product: | [Developer tools] valgrind | Reporter: | faragon.github |
Component: | memcheck | Assignee: | Ivo Raisr <ivosh> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | fweimer, ivosh, nix |
Priority: | NOR | ||
Version First Reported In: | 3.13.0 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: |
Replace wmemchr() and wcsnlen() on Linux.
0001-Add-replacements-for-wmemchr-and-wcsnlen-on-Linux.patch Add-replacements-for-wmemchr-and-wcsnlen-on-Linux |
Description
faragon.github
2018-01-12 13:02:17 UTC
Could it be related to this other bug (2009): (?) https://bugzilla.redhat.com/show_bug.cgi?id=518247 I bet this is just a matter of new IFUNC resolvers. memchr and rawmemchr are in the list; wcsnlen and wmemchr are not. FYI, with glibc 2.27 I see ==38614== Conditional jump or move depends on uninitialised value(s) ==38614== at 0x5190B37: __wmemchr_avx2 (in /usr/lib/libc-2.27.so) ==38614== by 0x5104D98: internal_fnwmatch (in /usr/lib/libc-2.27.so) ==38614== by 0x5107F4C: fnmatch@@GLIBC_2.2.5 (in /usr/lib/libc-2.27.so) ==38614== by 0x409518: print_dir (in /pkg/coreutils/8.29/usr/bin/ls) ==38614== by 0x402FCC: main (in /pkg/coreutils/8.29/usr/bin/ls) which is clearly related. I'll see if I can work up a patch. Created attachment 111086 [details]
Replace wmemchr() and wcsnlen() on Linux.
Patch attached. There may be more things which need replacement, but "valgrind /bin/ls" works for me on glibc 2.27 without spurious errors now.
Will send to Ivo to see what he thinks of it.
Thank you for the patch. I had to make some fixes to make it actually work and do not introduce regressions. Please review the attachment. Created attachment 111142 [details]
0001-Add-replacements-for-wmemchr-and-wcsnlen-on-Linux.patch
Fixed patch originally from Nick Alcock.
I'll admit I don't understand why wmemchr() and wcsnlen() need to take UInt *s when the other wide character functions in the same file are quite happy with Ints, but if you prefer it, I don't see any problem doing it that way. Oh, alright, let's make it Int also for wcslen() so the whole file is consistent. Created attachment 111143 [details]
Add-replacements-for-wmemchr-and-wcsnlen-on-Linux
Make wcslen() operate on Int as well.
OK! I don't understand how my original wcsnlen() is compiling for me at all: I mean it's obvious that I forgot I was writing a while and changed to a for halfway through the statement, leading to something grossly syntactically invalid. I wonder why it didn't get a compilation error for me? (Because it didn't, and still doesn't. Weird upon weird! Ah well I'll be moving off this GCC release soon anyway, so I guess I don't care much. You caught it and that's what matters.) :-) There was also a problem with the actual replacement definition. For example wcsnlen had the following: #if defined(VGO_linux) STRNLEN(VG_Z_LIBC_SONAME, wcsnlen) STRNLEN(VG_Z_LIBC_SONAME, __GI_wcsnlen) #endif This could not have worked. OK OK I was clearly on some serious drugs that day. God only knows what I actually compiled (though it does seem to work, and is still working). I have now replaced it with your fixed patch, which also works while having the significant advantage of not being full of horrible syntax errors. :) Pushed as 23185f46a17079fcfca35c2ef335a598812cb23b. https://sourceware.org/git/?p=valgrind.git;a=commitdiff;h=23185f46a17079fcfca35c2ef335a598812cb23b |