The mailer of <a href="http://common-lisp.net">common-lisp.net</a> dropped to the floor the previous transmission of the following message, so here it is again.<br><br>Cheers,<br><br>Jean-Claude Beaudoin<br><br><br><div class="gmail_quote">
---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Jean-Claude Beaudoin</b> <span dir="ltr"><<a href="mailto:jean.claude.beaudoin@gmail.com">jean.claude.beaudoin@gmail.com</a>></span><br>Date: Wed, Mar 25, 2009 at 1:13 AM<br>
Subject: CFFI should defend itself against fragile handling of narrow return types in SBCL on x86!<br>To: <a href="mailto:cffi-devel@common-lisp.net">cffi-devel@common-lisp.net</a><br><br><br><br>Recent versions of GCC appear to be leaving spurious bits in the %eax register used to return the value of a C function on x86 based platforms when the return type is narrower than 32 bits (ie: short or char). SBCL does not defend itself against such register pollution and will return an incorrect value made up of those spurious bits in addition to the intended value. A partial fix for "signed" short and char has appeared in SBCL 1.0.25 but the "unsigned" cases are still vulnerable. I suggest that CFFI should defend itself against that dangerously permissive handling of narrow return types in SBCL through the use of a few filtering functions to be applied in those relevant cases, at least until SBCL fixes the issue for good.<br>
<br>Here is attached a patch against CFFI 0.10.4 with a version of the required code.<br><br>I also attach a set of test files that can be used to illustrate the problem.<br><br>Cheers,<br><font color="#888888"><br>Jean-Claude Beaudoin<br>
<br>
</font></div><br>