pushed: Add support for DWARF-based fixed point types

Joel Brobecker brobecker@adacore.com
Mon Nov 23 04:27:11 GMT 2020


> We pass mpz_export a buffer of 8 bytes (statically allocated in
> write_fp_test), but GMP decides it needs to write 16 bytes, hence the
> overflow.
> 
> I tried to read the GMP doc, but I am familiar with its concepts, so I
> don't really understand if we are using the API correctly or not.

I found the source of the problem, which was in a way subtle-enough
that you really have to pay attention to these details (which,
luckily, are handled automatically thanks to our minor C++-ification
of GMP in gmp-utils), and yet so obvious once you find it.
Attached is the patch that I will push later today (need to run RSN,
and don't want to make a mistake because I'm rushing).

I think this error might be highlighting a weakness, though. I need
to investigate more, but I'm thinking it might be wise to add some
checks during export that the buffer size is large enough to fit
the value. In other words, I'm thinking of having our own
safe_mpz_export which double-checks the size of the buffer according
to the formula given by the documentation, and raises an error if
too small.

The fact that GMP happily goes beyond the end of the buffer is
a bit unexpected, still. Maybe something to report to the GMP team.

Later!

-- 
Joel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-stack-smashing-error-during-gdb_mpq_write_fixed_.patch
Type: text/x-diff
Size: 2946 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20201123/1515edf6/attachment.bin>


More information about the Gdb-patches mailing list