[mpich-devel] Issue with MPI_Error_string() for user-defined codes/clases

Rob Latham robl at mcs.anl.gov
Wed Apr 23 14:12:52 CDT 2014



On 04/23/2014 05:20 AM, Lisandro Dalcin wrote:
> On 23 April 2014 00:55, Rob Latham <robl at mcs.anl.gov> wrote:
>>
>>
>> On 04/22/2014 04:04 AM, Lisandro Dalcin wrote:
>>>
>>> The following simple tests segfaults. A quick fix would be to return
>>> an empty string in MPIR_Err_get_dynerr_string() (file dynerrutil.c),
>>
>>
>> I don't muck around in this code very often, so after thinking about it for
>> a bit, and coming up with another way to do it, I opened a ticket so i could
>> get a second (third, I guess) opinion:
>>
>> https://trac.mpich.org/projects/mpich/ticket/2067
>>
>
> IMHO your patch complicates things too much, I'm still in support of
> this slightly refined version that removes the usage of empty string
> constants (Rob, could you upload this patch to the ticket?):

you win! yes, my approach quickly got out of hand.  I'll go with your 
approach after running it through jenkins.

==rob

>
> $ git diff
> diff --git a/src/mpi/errhan/dynerrutil.c b/src/mpi/errhan/dynerrutil.c
> index 943e8c3..2e3bb27 100644
> --- a/src/mpi/errhan/dynerrutil.c
> +++ b/src/mpi/errhan/dynerrutil.c
> @@ -48,6 +48,7 @@ static const char
> *(user_class_msgs[ERROR_MAX_NCLASS]) = { 0 };
>   static const char *(user_code_msgs[ERROR_MAX_NCODE]) = { 0 };
>   static int  first_free_class = 0;
>   static int  first_free_code  = 1;  /* code 0 is reserved */
> +static const char empty_error_string[1] = { 0 };
>
>   /* Forward reference */
>   const char *MPIR_Err_get_dynerr_string( int code );
> @@ -297,11 +298,13 @@ const char *MPIR_Err_get_dynerr_string( int code )
>       if (errcode) {
>    if (errcode < first_free_code) {
>       errstr = user_code_msgs[errcode];
> +    if (!errstr) errstr = empty_error_string;
>    }
>       }
>       else {
>    if (errclass < first_free_class) {
>       errstr = user_class_msgs[errclass];
> +    if (!errstr) errstr = empty_error_string;
>    }
>       }
>
>
>

-- 
Rob Latham
Mathematics and Computer Science Division
Argonne National Lab, IL USA


More information about the devel mailing list