[PATCH] D54739: [Sanitizer] intercept setvbuf on other platforms where it is supported

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 20 14:20:48 PST 2018


krytarowski added inline comments.


================
Comment at: test/sanitizer_common/TestCases/Posix/setvbuf.cc:19
 
   setbuf(stdout, buf);
 
----------------
vitalybuka wrote:
> krytarowski wrote:
> > vitalybuka wrote:
> > > krytarowski wrote:
> > > > devnexen wrote:
> > > > > vitalybuka wrote:
> > > > > > hm, we do not intercept this one, and two below
> > > > > Seemed a near future plan though but I can always delete them if really wished ?
> > > > Do not delate! setvbuf() is an internal implementation for setbuffer(3), setlinebuf(3) and setbuf(3).
> > > > 
> > > > https://nxr.netbsd.org/xref/src/lib/libc/stdio/setbuffer.c
> > > > https://nxr.netbsd.org/xref/src/lib/libc/stdio/setbuf.c
> > > > 
> > > > If you do not support them on some OS, please ifdef them out.
> > > I tried to read first byte from the buf on linux and it fails on uninitialized read everywhere but setvbuf
> > > 
> > I've included these tests on purpose, expecting that all the variations will be handled properly with a single interceptor.
> Sorry, I am not asking to remove them. 
> Just pointing out that we probably need more interceptors on other platforms.
> I tried to read first byte from the buf on linux and it fails on uninitialized read everywhere but setvbuf

It looks like glibc does not treat setvbuf(3) as the internal version.

```
void
setbuf (FILE *fp, char *buf)
{
  _IO_setbuffer (fp, buf, BUFSIZ);
}
```

and everywhere internal symbols are in use as the code is going deeper.

Summary: Interceptors for the remaining variations seem to be needed for GLIBC. They won't make harm for NetBSD.

You will need to add a BUFSIZ to platform constants, for use in the interceptors.


Repository:
  rL LLVM

https://reviews.llvm.org/D54739





More information about the llvm-commits mailing list