[asterisk-dev] app_voicemail.c

Jim Capp jcapp at anteil.com
Thu Apr 16 10:57:26 CDT 2009


Kevin,

    You are, of course, assuming that app_voicemail is compiled as a 
module.  When it is compiled as part of the asterisk binary, however, 
the little nasty rears its ugly head.

Jim


>
> ------------------------------------------------------------------------
>
> Subject:
> Re: [asterisk-dev] bug in app_voicemail.c
> From:
> "Kevin P. Fleming" <kpfleming at digium.com>
> Date:
> Thu, 16 Apr 2009 10:18:26 -0500
> To:
> Asterisk Developers Mailing List <asterisk-dev at lists.digium.com>
>
> To:
> Asterisk Developers Mailing List <asterisk-dev at lists.digium.com>
>
>
> Jim Capp wrote:
>
>   
>> The problem is that since my_umask is not declared static, compilers are
>> not required to persist its value. As such, some highly optimized
>> compilers will assign it a cpu register rather than variable space on
>> the stack. Since my_umask is only set during module load, subsequent
>> uses of my_umask are unreliable as the register will surely have been
>> overwritten prior to its next use.
>>     
>
> This is incorrect. Since 'my_umask' is a module level variable (file
> scope) its value *must* be preserved across function calls, since all
> functions within that module share that variable. In addition, since it
> is not static, then it becomes an exported symbol from that module and
> could be accessed from other modules (compilation units). Without the
> compiler being told otherwise, it *must* treat the variable this way,
> including placing the symbol for this variable into the run-time symbol
> table for the module for the linker to be able to resolve references to
> at runtime. With all of this, I do not see how it could ever be placed
> into a register, and that's not even taking into account the fact that
> the variable can be accessed from multiple functions in app_voicemail
> that can be called from various different call paths, and it would not
> be possible to ensure that the register that had been assigned was
> preserved through all those code paths.
>
> Now, in spite of all of that, making this variable static *is* the right
> thing to do, since it does not need to be exported (in fact, for nearly
> all modules in Asterisk, file-scope variables should *always* be
> static). If this fixes the bug that's great, but I without more evidence
> I don't see how the reason why it fixes the bug is what you have described.
>
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20090416/d75135fc/attachment.htm 


More information about the asterisk-dev mailing list