> On 6 Oct 2016, at 13:43, Mateusz Jemielity <m.jemiel...@is-wireless.com> 
> wrote:
> 
> I'm using valgrind built from SVN, r16025. I encountered helgrind
> complaining about invalid argument used with pthread_rwlock_destroy, for
> variable initialized with PTHREAD_RWLOCK_INITIALIZER. Is this a known thing?
> Am I doing something wrong? I searched the mailing list archives on
> https://sourceforge.net/p/valgrind/mailman/valgrind-users/, but couldn't
> find anything. I'm asking because I think pthreads allows me to destroy
> rwlock initialized that way.
> 
> I reproduced this with minimal test case on Ubuntu 14.04:
> $ lsb_release -a
> No LSB modules are available.
> Distributor ID:       Ubuntu
> Description:  Ubuntu 14.04.5 LTS
> Release:      14.04
> Codename:     trusty
> $ cat pthread_rwlock_destroy.c 
> # define _POSIX_C_SOURCE 20161006L
> 
> #include <assert.h>
> #include <pthread.h>
> 
> int main(void)
> {
>  pthread_rwlock_t l = PTHREAD_RWLOCK_INITIALIZER;
>  assert(0 == pthread_rwlock_destroy(&l));
>  return 0;
> }

According to the man page:

> The pthread_rwlock_destroy() function is used to destroy a read/write lock 
> previously created with pthread_rwlock_init().

You did not create the lock with pthread_rwload_init() - you used a static 
initialisation. Therefore my understanding is that you do not need to (and 
should not) call pthread_rwlock_destroy().

-- 
Alex Bligh





------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to