Re: Memory corruption for host double format different from target double format

Yao Qi
2012-08-10T10:37:57Z

On Friday, August 10, 2012 11:32:53 AM Thomas Schwinge wrote:
> gdbarch.c:verify_gdbarch:
>
> [...]
> /* Skip verify of float_bit, invalid_p == 0 */
> if (gdbarch->float_format == 0)
> gdbarch->float_format = floatformats_ieee_single;
> /* Skip verify of double_bit, invalid_p == 0 */
> if (gdbarch->double_format == 0)
> gdbarch->double_format = floatformats_ieee_double;
> /* Skip verify of long_double_bit, invalid_p == 0 */
> if (gdbarch->long_double_format == 0)
> gdbarch->long_double_format = floatformats_ieee_double;
> [...]
>
> That is, if set_gdbarch_double_format has not been called, it will
> default to floatformats_ieee_double -- even though set_gdbarch_double_bit
> may have been called setting it unequal to the 64-bit double format.
> Hmm, and gdbarch.c:verify_gdbarch has the following comment on top of it:
> »Ensure that all values in a GDBARCH are reasonable.« ;-)

Looks like some checking like this is missing?

gdbarch->float_format->totalsize <= gdbarch->float_bit
gdbarch->double_format->totalsize <= gdbarch->double_bit

--
Yao (齐尧)