This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Do not create invalid pointers in C code of string functions.
- From: Torvald Riegel <triegel at redhat dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: GLIBC Devel <libc-alpha at sourceware dot org>, "H.J. Lu" <hjl dot tools at gmail dot com>
- Date: Tue, 07 Jul 2015 13:43:05 +0200
- Subject: Re: [PATCH] Do not create invalid pointers in C code of string functions.
- Authentication-results: sourceware.org; auth=none
- References: <1435949673 dot 10077 dot 62 dot camel at localhost dot localdomain> <20150703194821 dot GA29061 at domone>
On Fri, 2015-07-03 at 21:48 +0200, OndÅej BÃlka wrote:
> On Fri, Jul 03, 2015 at 08:54:33PM +0200, Torvald Riegel wrote:
> > Some of the x86 string functions create pointers based on input strings
> > that may be outside of the input strings. When this happens in C code,
> > the compiler can potentially detect this, leading to warnings in
> > application code when those string functions are inlined. Perform those
> > operations in the assembly code instead of the C code to fix this.
> >
> > The respective operations all substract 1; this patch may prevent the
> > compiler from doing that at compile time if the input strings have known
> > addresses. I haven't measured performance, but I'd guess that it's in
> > the noise except perhaps for microbenchmarks with tiny or empty strings.
> >
> > If someone wants to propose a better patch, please do so. But do it
> > quick because this issue currently prevents x86 builds with a recent
> > GCC :)
> >
> While patch itself is correct it would be better to just delete these.
> Performance-wise these are lot slower than libcall and I am surprised
> that anybody used these.
I have just committed this patch to fix the correctness/build problems.
I am not sufficiently familiar with the performance of the string
functions to address your other suggestion.