potential bug in pv_subtract in prologue-value.c
CF Bolz-Tereick
cfbolz@gmx.de
Mon Nov 6 15:19:57 GMT 2023
Hi all!
this is pretty random, but I was reading some code in prologue-value.c
out of curiosity, and spotted something that looked rather
suspicious/buggy to me. isn't the call to constant_last in pv_subtract
wrong? constant_last potentially swaps the arguments of pv_subtract,
which looks wrong, because subtraction is not commutative:
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/prologue-value.c;h=13bf4362069e99301dba7d99f039f547768b264d;hb=HEAD#l128
This is of course a very theoretical bug, I would suspect it's pretty
hard to demonstrate this problem in any "real" machine code that is
thrown at prologue analysis on one of the platforms that uses it. but
I'd be happy to write a patch with a fix and a unit test if somebody
else finds it weird too.
Cheers,
CF
More information about the Gdb
mailing list