[Developers] Fwd: [CactusMaint] CactusUtils/2079: Patch for thorn TimerReport: Output timer reports to a file instead of to stdout

Thomas Radke tradke at aei.mpg.de
Fri May 18 03:29:41 CDT 2007


Erik Schnetter wrote:
>>   * Declaring a large local array 'char filename [10000];' in Output.c
>>     is potentially dangerous and probably overkill anyway. I reduced
>>     its size to 200 characters which should suffice.
> 
> 
> I think Posix specifies that files names can be up to 1023 characters  
> long.  What if a file name is longer, e.g. because it contains a  URL?  
> File names can easily be longer than 80 characters, so a hard  limit of 
> 200 is dangerously close.

This is true.

> Why do you think that 10000 is dangerous?  This space will be  allocated 
> on the stack for a brief time.  Do you think that the stack  cannot 
> handle this?  BSSN_MoL has so many local variables that it  requires 
> much more stack space, or the compiler has to allocate the  variables 
> somewhere else (which may happen).  Is there a machine  where stack 
> space is an issue?
> 
> I don't agree with a limit of 200.  I think the limit needs to be  
> either very large, or I will replace it by an automatic allocation,  
> although this complicates the code.

Yes, I would see the potential danger of stack overflow. Not necessarily 
in this function, agreed, as there is only one such array definition.
Still I'd rather implement it as an explicit array allocation even 
though it would slightly complicate the code.
Many trivial things, such as building a filename from some components, 
could be implemented so much more elegant with C++ strings. We should 
allow ourselfs to use standard C++ features more often also for Cactus 
infrastructure thorns.

-- 
Cheers, Thomas.


More information about the Developers mailing list