[phobos] thread priority bug

Brad Roberts braddr at puremagic.com
Sun Mar 17 16:49:41 PDT 2013


I just setup the freebsd64 tester to apply this (untested, though it 
builds) patch to all builds it does.  Hopefully that will help expose 
what's going on.  To be clear, the occasional failure is NOT freebsd or 
even freebsd/64 specific, just seems to happen there a lot more 
frequently than other platforms.

> diff --git a/src/core/stdc/string.d b/src/core/stdc/string.d
> index 32d36ca..6a9dd4b 100644
> --- a/src/core/stdc/string.d
> +++ b/src/core/stdc/string.d
> @@ -42,5 +42,6 @@ pure size_t strspn(in char* s1, in char* s2);
>  pure char*  strstr(in char* s1, in char* s2);
>  char*  strtok(char* s1, in char* s2);
>  char*  strerror(int errnum);
> +int    strerror_r(int errnum, char* s1, size_t n);
>  pure size_t strlen(in char* s);
>  char*  strdup(in char *s);
> diff --git a/src/core/thread.d b/src/core/thread.d
> index 5d9958a..2706a6a 100644
> --- a/src/core/thread.d
> +++ b/src/core/thread.d
> @@ -874,6 +874,8 @@ class Thread
>          }
>          else version( Posix )
>          {
> +            import core.stdc.string;
> +
>              // NOTE: pthread_setschedprio is not implemented on linux, so use
>              //       the more complicated get/set sequence below.
>              //if( pthread_setschedprio( m_addr, val ) )
> @@ -883,10 +885,18 @@ class Thread
>              sched_param param;
>
>              if( pthread_getschedparam( m_addr, &policy, &param ) )
> -                throw new ThreadException( "Unable to set thread priority" );
> +            {
> +                char[1024] buf;
> +                strerror_r(errno, buf.ptr, buf.sizeof);
> +                throw new ThreadException( ("Unable to get sched param: " ~ buf).idup );
> +            }
>              param.sched_priority = val;
>              if( pthread_setschedparam( m_addr, policy, &param ) )
> -                throw new ThreadException( "Unable to set thread priority" );
> +            {
> +                char[1024] buf;
> +                strerror_r(errno, buf.ptr, buf.sizeof);
> +                throw new ThreadException( ("Unable to set sched param: " ~ buf).idup );
> +            }
>          }
>      }



More information about the phobos mailing list