[cfe-users] Problem with address sanitizer stack traces

2015-11-24 Thread Rainer Gerhards via cfe-users
Hi all,

first, thanks for the great tool, especially the address sanitizer. I
have a multi-threaded program, where I get a segfault due to access to
free'd memory in one thread. In the report, I see references to where
this memory block was malloc'ed and free'ed. Unfortunately, these
later two stack traces just include 2 and 3 stack frames, where it
would need to be around 15. Most importantly, the information I really
need is missing due to that.

I tried to explicitely set

ASAN_OPTIONS=verbosity=1:malloc_context_size=20

even though malloc_context_size should be 30 by default. I know
ASAN_OPTIONS is used, because my output now is verbose.

I compile with

-g -W -Wall -Wformat-security -Wshadow -Wcast-align -Wpointer-arith
-Wmissing-format-attribute -fsanitize=address -fno-omit-frame-pointer
-O0

Note that I added -O0 in a desparate effort to try to get to larger
stack traces. Nothing changes if I leave it out.

I than wrote a small single-threaded test program, and there large
stack traces are reported.

Does anyone have any advise on how to get to larger stack traces? Or
at least what could be the root cause of this problem?

Any help would be deeply appreciated.

Thanks,
Rainer
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] static inline functions in headers and -Wunused-function

2016-01-27 Thread Rainer Gerhards via cfe-users
Hi all,

I try to use -Werror -Wall for my project, which includes -Wunused-function.

Unfortunately, I receive a couple of warnings from library header files
which include

static inline ... func() { ... }

These functions are indeed often unused, but as of my understanding this
should be perfectly fine with static inline functions (they just replace
macro definitions in a better way).

Am I wrong here? What's the best path to fix this?

version: Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on
LLVM 3.6.2)

Any help is deeply appreciated.

Rainer
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] static inline functions in headers and -Wunused-function

2016-01-27 Thread Rainer Gerhards via cfe-users
Thanks David and Richard for the explanations. This really helps. Looks
like I need to re-read my language manual ;)

Rainer

2016-01-27 18:09 GMT+01:00 Richard via cfe-users :

>
> [Please reply *only* to the list and do not include my email directly
> in the To: or Cc: of your reply; otherwise I will not see your reply.
> Thanks.]
>
> In article  eq7hicg5bj0jbysoofmvqv3fy4b6p3xaaeq...@mail.gmail.com>,
> David Blaikie via cfe-users  writes:
>
> > On Wed, Jan 27, 2016 at 3:01 AM, Rainer Gerhards via cfe-users <
> > cfe-users@lists.llvm.org> wrote:
>
> > > Am I wrong here? What's the best path to fix this?
> > >
> >
> > Ish. They shuold probably just be "inline" without the static.
>
> +1 for all the reasons David explains :-).
>
> (He beat me to it! LOL.)
>
> --
> "The Direct3D Graphics Pipeline" free book <
> http://tinyurl.com/d3d-pipeline>
>  The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
>  The Terminals Wiki <http://terminals.classiccmp.org>
>   Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] Code locations from the Memory Sanitizer

2017-04-28 Thread Rainer Gerhards via cfe-users
2017-04-28 12:25 GMT+02:00 Erik de Castro Lopo via cfe-users
:
> Hi all,
>
> I've tried Clang versions 3.6, 3.9 and 5.0 (all installed from Debian
> packages on a Debian x86_64 machine), but I still can't get Memory
> Sanitizer to give me the error file and line number locations.
>
> The project is
>
>http://github.com/erikd/libsndfile
>
> and I'm configuring/building it with eg:
>
> CC=clang-5.0
> CXX=clang++-5.0
> CFLAGS="-fsanitize=memory -fno-omit-frame-pointer -g 
> -Wno-expansion-to-defined"
> CXXFLAGS=$CFLAGS
> ./configure --enable-werror --disable-shared
> make clean all check
>
> and I get:
>
> broadcast_test : broadcast.rf64 ..
> Uninitialized bytes in __interceptor_write at offset 36 inside 
> [0x7100, 104)
> ==15113==WARNING: MemorySanitizer: use-of-uninitialized-value
> #0 0x67802e  (/home/erik/Git/libsndfile/tests/command_test+0x67802e)
> #1 0x600404  (/home/erik/Git/libsndfile/tests/command_test+0x600404)
> #2 0x5f72f6  (/home/erik/Git/libsndfile/tests/command_test+0x5f72f6)
> #3 0x4be48b  (/home/erik/Git/libsndfile/tests/command_test+0x4be48b)
> #4 0x4c06d6  (/home/erik/Git/libsndfile/tests/command_test+0x4c06d6)
> #5 0x4b1cfc  (/home/erik/Git/libsndfile/tests/command_test+0x4b1cfc)
> #6 0x4a10c6  (/home/erik/Git/libsndfile/tests/command_test+0x4a10c6)
> #7 0x495dbf  (/home/erik/Git/libsndfile/tests/command_test+0x495dbf)
> #8 0x7f3f37cf22b0  (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
> #9 0x41ef79  (/home/erik/Git/libsndfile/tests/command_test+0x41ef79)
>
> I expected to get file and line number position as shown in the documentation.
>
> Clues?

I often need to set the ASAN_SYMBOLIZER_PATH:

https://clang.llvm.org/docs/AddressSanitizer.html#id4

It often tends to be wrong by package default...

HTH
Rainer

>
> Erik
> --
> --
> Erik de Castro Lopo
> http://www.mega-nerd.com/
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] TSAN and pthread_setcancelstate()

2017-12-29 Thread Rainer Gerhards via cfe-users
Hi all,

I hope this is the right list for my question. If not, please accept
my apologies -- in that case I would also appreciate if you could tell
me the right place to ask.

I am using TSAN together with clang (3,4,5) on Linux (in this Case
Ubuntu 16.04). It works great, but I always get race reports (sample
after my sig) on pthread_setcancelstate(). The POSIX doc states that
it sets the cancellation state for the *current thread* so there
should be no cross-thread data races. To validate this, I have also
checked the GNU libc and pthread implemenation and the both access
thread-local storage.

So I wonder what I may be doing wrong and most importantly what I can
decently do in order to get rid of the TSAN message (false positive?).
I know I can disable TSAN on a function basis, but that is a but
clumpsy as I do not want to disable if for more but the
pthread_setcancelstate. In an extreme, I probably need to move it to
an inline wrapper, but I don't consider this to be really clean.

Any advise, especially on the root cause, would be much appreciated.
It makes me kind of nervous not understanding why this happens at
all...

Thanks in advance,
Rainer

Sample Report:
WARNING: ThreadSanitizer: data race (pid=103016)
  Write of size 1 at 0x7c00 by main thread:
#0 pthread_setcancelstate  (rsyslogd+0x0043a830)
#1 qqueueEnqMsg /home/rger/proj/rsyslog/runtime/queue.c:3039:3
(rsyslogd+0x005a20d9)
#2 submitMsg2 /home/rger/proj/rsyslog/tools/rsyslogd.c:1015:2
(rsyslogd+0x004b08b0)
#3 logmsgInternal_doWrite
/home/rger/proj/rsyslog/tools/rsyslogd.c:864:3
(rsyslogd+0x004b0cc0)
#4 processImInternal
/home/rger/proj/rsyslog/tools/rsyslogd.c:1566:4
(rsyslogd+0x004b0c4b)
#5 mainloop /home/rger/proj/rsyslog/tools/rsyslogd.c:1787:3
(rsyslogd+0x004b2df5)
#6 main /home/rger/proj/rsyslog/tools/rsyslogd.c:1965:2
(rsyslogd+0x004b15cf)

  Previous write of size 1 at 0x7c00 by thread T1:
#0 pthread_setcancelstate  (rsyslogd+0x0043a830)
#1 ConsumerReg /home/rger/proj/rsyslog/runtime/queue.c:2029:2
(rsyslogd+0x0059e6f9)
#2 wtiWorker /home/rger/proj/rsyslog/runtime/wti.c:366:14
(rsyslogd+0x00591683)
#3 wtpWorker /home/rger/proj/rsyslog/runtime/wtp.c:415:2
(rsyslogd+0x0058e371)

  Thread T1 'rs:main Q[DA]:R' (tid=103049, running) created by main thread at:
#0 pthread_create  (rsyslogd+0x0042dc76)
#1 wtpStartWrkr /home/rger/proj/rsyslog/runtime/wtp.c:464:11
(rsyslogd+0x0058cf50)
#2 wtpAdviseMaxWorkers /home/rger/proj/rsyslog/runtime/wtp.c:520:4
(rsyslogd+0x0058c783)
#3 qqueueAdviseMaxWorkers
/home/rger/proj/rsyslog/runtime/queue.c:380:3
(rsyslogd+0x0059f899)
#4 qqueueStart /home/rger/proj/rsyslog/runtime/queue.c:2437:2
(rsyslogd+0x005990bf)
#5 StartDA /home/rger/proj/rsyslog/runtime/queue.c:450:9
(rsyslogd+0x005ae6cf)
#6 InitDA /home/rger/proj/rsyslog/runtime/queue.c:514:3
(rsyslogd+0x0059f281)
#7 qqueueStart /home/rger/proj/rsyslog/runtime/queue.c:2430:3
(rsyslogd+0x0059905d)
#8 startMainQueue /home/rger/proj/rsyslog/tools/rsyslogd.c:829:2
(rsyslogd+0x004afa7f)
#9 activateMainQueue
/home/rger/proj/rsyslog/runtime/rsconf.c:817:10
(rsyslogd+0x00524349)
#10 activate /home/rger/proj/rsyslog/runtime/rsconf.c:883:2
(rsyslogd+0x0051fbf8)
#11 initAll /home/rger/proj/rsyslog/tools/rsyslogd.c:1507:2
(rsyslogd+0x004b2b2c)
#12 main /home/rger/proj/rsyslog/tools/rsyslogd.c:1957:2
(rsyslogd+0x004b151e)

SUMMARY: ThreadSanitizer: data race
(/home/rger/proj/rsyslog/tools/rsyslogd+0x43a830) in
__interceptor_pthread_setcancelstate
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] TSAN and pthread_setcancelstate()

2017-12-30 Thread Rainer Gerhards via cfe-users
Adding to my own question:

I have tried to use __attribute__((no_sanitize("thread"))) and
blacklisting to work around the issue, but without any success.

Details in commit
https://github.com/rgerhards/rsyslog/commit/8e7625a5b21924518739acf17712f028c4c25241

This has now actually become a blocker for me in regard to adoption of
TSAN. Any help would be highly appreciated!

Thanks and happy new year,
Rainer

2017-12-29 19:01 GMT+01:00 Rainer Gerhards :
> Hi all,
>
> I hope this is the right list for my question. If not, please accept
> my apologies -- in that case I would also appreciate if you could tell
> me the right place to ask.
>
> I am using TSAN together with clang (3,4,5) on Linux (in this Case
> Ubuntu 16.04). It works great, but I always get race reports (sample
> after my sig) on pthread_setcancelstate(). The POSIX doc states that
> it sets the cancellation state for the *current thread* so there
> should be no cross-thread data races. To validate this, I have also
> checked the GNU libc and pthread implemenation and the both access
> thread-local storage.
>
> So I wonder what I may be doing wrong and most importantly what I can
> decently do in order to get rid of the TSAN message (false positive?).
> I know I can disable TSAN on a function basis, but that is a but
> clumpsy as I do not want to disable if for more but the
> pthread_setcancelstate. In an extreme, I probably need to move it to
> an inline wrapper, but I don't consider this to be really clean.
>
> Any advise, especially on the root cause, would be much appreciated.
> It makes me kind of nervous not understanding why this happens at
> all...
>
> Thanks in advance,
> Rainer
>
> Sample Report:
> WARNING: ThreadSanitizer: data race (pid=103016)
>   Write of size 1 at 0x7c00 by main thread:
> #0 pthread_setcancelstate  (rsyslogd+0x0043a830)
> #1 qqueueEnqMsg /home/rger/proj/rsyslog/runtime/queue.c:3039:3
> (rsyslogd+0x005a20d9)
> #2 submitMsg2 /home/rger/proj/rsyslog/tools/rsyslogd.c:1015:2
> (rsyslogd+0x004b08b0)
> #3 logmsgInternal_doWrite
> /home/rger/proj/rsyslog/tools/rsyslogd.c:864:3
> (rsyslogd+0x004b0cc0)
> #4 processImInternal
> /home/rger/proj/rsyslog/tools/rsyslogd.c:1566:4
> (rsyslogd+0x004b0c4b)
> #5 mainloop /home/rger/proj/rsyslog/tools/rsyslogd.c:1787:3
> (rsyslogd+0x004b2df5)
> #6 main /home/rger/proj/rsyslog/tools/rsyslogd.c:1965:2
> (rsyslogd+0x004b15cf)
>
>   Previous write of size 1 at 0x7c00 by thread T1:
> #0 pthread_setcancelstate  (rsyslogd+0x0043a830)
> #1 ConsumerReg /home/rger/proj/rsyslog/runtime/queue.c:2029:2
> (rsyslogd+0x0059e6f9)
> #2 wtiWorker /home/rger/proj/rsyslog/runtime/wti.c:366:14
> (rsyslogd+0x00591683)
> #3 wtpWorker /home/rger/proj/rsyslog/runtime/wtp.c:415:2
> (rsyslogd+0x0058e371)
>
>   Thread T1 'rs:main Q[DA]:R' (tid=103049, running) created by main thread at:
> #0 pthread_create  (rsyslogd+0x0042dc76)
> #1 wtpStartWrkr /home/rger/proj/rsyslog/runtime/wtp.c:464:11
> (rsyslogd+0x0058cf50)
> #2 wtpAdviseMaxWorkers /home/rger/proj/rsyslog/runtime/wtp.c:520:4
> (rsyslogd+0x0058c783)
> #3 qqueueAdviseMaxWorkers
> /home/rger/proj/rsyslog/runtime/queue.c:380:3
> (rsyslogd+0x0059f899)
> #4 qqueueStart /home/rger/proj/rsyslog/runtime/queue.c:2437:2
> (rsyslogd+0x005990bf)
> #5 StartDA /home/rger/proj/rsyslog/runtime/queue.c:450:9
> (rsyslogd+0x005ae6cf)
> #6 InitDA /home/rger/proj/rsyslog/runtime/queue.c:514:3
> (rsyslogd+0x0059f281)
> #7 qqueueStart /home/rger/proj/rsyslog/runtime/queue.c:2430:3
> (rsyslogd+0x0059905d)
> #8 startMainQueue /home/rger/proj/rsyslog/tools/rsyslogd.c:829:2
> (rsyslogd+0x004afa7f)
> #9 activateMainQueue
> /home/rger/proj/rsyslog/runtime/rsconf.c:817:10
> (rsyslogd+0x00524349)
> #10 activate /home/rger/proj/rsyslog/runtime/rsconf.c:883:2
> (rsyslogd+0x0051fbf8)
> #11 initAll /home/rger/proj/rsyslog/tools/rsyslogd.c:1507:2
> (rsyslogd+0x004b2b2c)
> #12 main /home/rger/proj/rsyslog/tools/rsyslogd.c:1957:2
> (rsyslogd+0x004b151e)
>
> SUMMARY: ThreadSanitizer: data race
> (/home/rger/proj/rsyslog/tools/rsyslogd+0x43a830) in
> __interceptor_pthread_setcancelstate
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users