I have attached a small gzipped tar file including a sample program that CIL handles incorrectly on my Macbook Pro, along with a make file, an SVN patch that fixes the problem (for me, at least), and CIL-generated C code from the good and bad versions.

On the Macbook Pro gcc attempts to generate some simple buffer overflow checking using __builtin_object_size, a builtin function whose specification (http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html) states that it "never evaluates its arguments for side-effects." When the argument to sprintf has a side effect, as in

sprintf(lp[nlp++], "%s/lib", root);

Cil generates C code that evaluates the side effect for both __builtin_object_size and __builtin___sprintf_chk.

My patch to src/frontc/cabs2cil.ml checks for "__builtin_object_size" and, following the pattern in "__builtin_constant_p", drops the side effects.

I have not been able to reproduce the problem on my Ubuntu system because its gcc does not generate the call to __builtin_object_size, and I have not figured out how gcc decides whether or not to generate it.

Jesse Draper

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

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to