The mailer of common-lisp.net dropped to the floor the previous transmission
of the following message, so here it is again.

Cheers,

Jean-Claude Beaudoin


---------- Forwarded message ----------
From: Jean-Claude Beaudoin <jean.claude.beaud...@gmail.com>
Date: Wed, Mar 25, 2009 at 1:13 AM
Subject: CFFI should defend itself against fragile handling of narrow return
types in SBCL on x86!
To: cffi-devel@common-lisp.net



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.

Here is attached a patch against CFFI 0.10.4 with a version of the required
code.

I also attach a set of test files that can be used to illustrate the
problem.

Cheers,

Jean-Claude Beaudoin

Attachment: cffi_0.10.4_sbcl_strict_widening.patch
Description: Binary data

Attachment: widening.tar.gz
Description: GNU Zip compressed data

_______________________________________________
cffi-devel mailing list
cffi-devel@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel

Reply via email to