Good catch. Fixing now.

-Nathan

On Mon, Mar 17, 2014 at 02:50:02PM +0100, Adrian Reber wrote:
> On Fri, Mar 14, 2014 at 10:18:06PM +0000, Hjelm, Nathan T wrote:
> > The preferred way is to use mca_base_var_find and then call 
> > mca_base_var_[set|get]_value. For performance sake we only look at the 
> > environment when the variable is registered.
> 
> I believe I found a bug in mca_base_var_set_value using bool variables:
> 
> #0  0x00007f6e0d8fb800 in mca_base_var_enum_bool_sfv (self=0x7f6e0dbabc20 
> <mca_base_var_enum_bool>, value=0, 
>     string_value=0x0) at ../../../../opal/mca/base/mca_base_var_enum.c:82
> #1  0x00007f6e0d8f45d6 in mca_base_var_set_value (vari=120, value=0x4031e6, 
> size=0, source=MCA_BASE_VAR_SOURCE_DEFAULT, 
>     source_file=0x0) at ../../../../opal/mca/base/mca_base_var.c:636
> #2  0x0000000000401e44 in main (argc=7, argv=0x7fffa72a0a78) at 
> ../../../../opal/tools/opal-restart/opal-restart.c:223
> 
> I am using set_value like this:
> 
> bool test=false;
> mca_base_var_set_value(idx, &test, 0, MCA_BASE_VAR_SOURCE_DEFAULT, NULL);
> 
> As the size is ignored I am just setting it to '0'.
> 
> mca_base_var_set_value() does 
> 
> ret = var->mbv_enumerator->string_from_value(var->mbv_enumerator,((int *) 
> value)[0], NULL);
> 
> which calls mca_base_var_enum_bool_sfv() with the last parameter set to NULL:
> 
> static int mca_base_var_enum_bool_sfv (mca_base_var_enum_t *self, const int 
> value,
>                                        const char **string_value)
> {
>     *string_value = value ? "true" : "false";
> 
>     return OPAL_SUCCESS;
> }
> 
> and here it tries to access the last parameter (string_value) which has
> been set to NULL. As I cannot find any usage of mca_base_var_set_value()
> with bool variables this code path has probably not been used until now.
> 
>               Adrian
> _______________________________________________
> devel mailing list
> de...@open-mpi.org
> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/devel
> Link to this post: 
> http://www.open-mpi.org/community/lists/devel/2014/03/14354.php

Attachment: pgpwRp9uOZE2z.pgp
Description: PGP signature

Reply via email to