supplierdeeply

DryOS localtime buffer

  • 1 Replies
  • 434 Views
*

Online reyalp

  • ******
  • 11084
DryOS localtime buffer
« on: 10 / November / 2013, 22:16:54 »
Advertisements
From http://chdk.setepontos.com/index.php?topic=10886.msg107057#msg107057

In my build, the static buffer x for localtime in generic/wrappers.c was just before the aram_heap variable.  Both testing and disassembly show it uses 10 words rather than 9, so it would overwrite the aram_heap variable.

I'm not sure if earlier versions of dryos used 10 words or not, the d10 firmware looks like it allocates 10 before calling.

For now I've just increased it to 10 for everything. This probably shouldn't be a static buffer since we call it from multiple tasks.
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 3538
Re: DryOS localtime buffer
« Reply #1 on: 11 / November / 2013, 15:08:28 »
That's a really good find. I hope it will solve some of the mysterious crashes.
I really don't know where the "9" words came from. All earlier DryOS disassemblies I've looked at show 10 words of allocated stack space: S5IS (r20), SX100 (r23), A470 (r23)...

Btw. I get this for man localtime (on Linux):
Quote
The return value points to a statically allocated struct which might be overwritten by subsequent calls to any of the date and time functions.
This particular Canon function is something like localtime_r(), which is supposed to be thread-safe (according to the POSIX manual).

 

Related Topics