On 11/25/2010 10:35 AM, Guilhem Bichot wrote:
> Hello Mats,
>
> Mats Kindahl a écrit, Le 24.11.2010 15:20:
>> #At file:///home/bzr/mkindahl/testing-trunk-bugfixing/ based on
>> revid:sergey.glukhov@stripped
>>
>> 3388 Mats Kindahl 2010-11-24
>> Bug #58455
>> Starting mysqld with defaults file without
>> extension cause segmentation fault
>> Bug occurs because fn_expand calls fn_format
>> with NULL as ext.
>
>> === added file 'mysql-test/t/mysqld--defaults-file.test'
>> --- a/mysql-test/t/mysqld--defaults-file.test 1970-01-01 00:00:00
>> +0000
>> +++ b/mysql-test/t/mysqld--defaults-file.test 2010-11-24 14:20:25
>> +0000
>> @@ -0,0 +1,31 @@
>> +#
>> +# mysqld --defaults-file
>> +#
>> +
>> +--source include/not_embedded.inc
>> +
>> +# All these tests refer to configuration files that do not exist
>> +
>> +--error 1
>> +--exec $MYSQLD --defaults-file=/path/with/no/extension
>> --print-defaults 2>&1
>
> I suggest writing in the test why MYSQLD is used instead of
> MYSQLD_BOOTSTRAP_CMD
Comment added. See the new patch.
>
>> === modified file 'mysys/mf_format.c'
>> --- a/mysys/mf_format.c 2009-04-19 01:21:33 +0000
>> +++ b/mysys/mf_format.c 2010-11-24 14:20:25 +0000
>> @@ -31,9 +31,12 @@ char * fn_format(char * to, const char *
>> reg1 size_t length;
>> size_t dev_length;
>> DBUG_ENTER("fn_format");
>> + DBUG_ASSERT(name != NULL);
>> + DBUG_ASSERT(extension != NULL);
>> DBUG_PRINT("enter",("name: %s dir: %s extension: %s flag: %d",
>> name,dir,extension,flag));
>>
>> +
>> /* Copy and skip directory */
>> name+=(length=dirname_part(dev, (startpos=(char *) name),
>> &dev_length));
>> if (length == 0 || (flag & MY_REPLACE_DIR))
>
> Two suggestions while you're in this function:
> - add in the function comment of fn_expand(), that it allocates memory
> (which will thus have to be freed).
It doesn't seem like it allocates memory. Both fn_expand() and
fn_format() appear to accept a buffer that it writes the results in.
> - "DBUG_ASSERT(result_path!=NULL)" could be removed, as it's preceded by
> if (... (result_path=...)==NULL) DBUG_RETURN
As you noted in the previous mail, it seems like these have been removed
(probably at the same time as the strdup() was removed, I seem to recall
that I did that).
/Matz