Aw: Re: Many core dumps in pthread_getspecific - how to debug?

Andre Meiser ortadur at web.de
Wed Jun 3 11:09:43 UTC 2015


On Wed, 3 Jun 2015 10:47 +0200 Erich Dollansky wrote:
> welcome!

thx ;)


> Can you get the sources and compile your own FreeBSD?

I got the source from here: http://svnweb.freebsd.org/base/releng/10.1/

And in lib/libkse/thread/thr_spec.c line 211-214 I found this:

    pthread = _get_curthread();

    /* Check if there is specific data: */
    if (pthread->specific != NULL && (unsigned int)key < PTHREAD_KEYS_MAX) {

If pthread is NULL than this will crash with a core dump. So I made a quick grep about the sources and at other places the return value of _get_curthread() is compared with NULL, e.g. thr_kern.c in line 601:

    if ((crit != NULL) && ((curthread = _get_curthread()) != NULL))

It looks like _get_curthread() may return NULL and than thr_spec.c line 214 has to look like this:

    if (pthread != NULL && pthread->specific != NULL && (unsigned int)key < PTHREAD_KEYS_MAX) {

But I'm new to FreeBSD, so I'm not sure if this will help to fix the problem. And I'm not experienced enough to compile my own FreeBSD, yet.


> Try first the source. The best mailing list for this should be
> 'stable' as it targets only the stable versions like yours.

Ok, thanks, I'll write it there, too.

Sincerely yours Andre.


More information about the freebsd-questions mailing list