[PATCH] Do not instrument string cst w/ unknown decl size (PR, sanitizer/71378)

Jakub Jelinek jakub@redhat.com
Fri Jun 3 11:00:00 GMT 2016


On Fri, Jun 03, 2016 at 12:53:06PM +0200, Martin Liška wrote:
> As seen in the issue, we try to instrument a global variable that contains a string
> constant. Following patch does not instrument in the size is variable (VLA).
> 
> Patch survives regression tests and bootstraps on x86_64-linux.
> It's questionable whether the same situation can also happen in asan_finish_file:
> 
>       FOR_EACH_DEFINED_VARIABLE (vnode)
> 	if (TREE_ASM_WRITTEN (vnode->decl)
> 	    && asan_protect_global (vnode->decl))
> 	  asan_add_global (vnode->decl, TREE_TYPE (type), v);

I think the STRING_CST with non-constant size is already a bug, so this
patch looks to me just like a workaround for a bug that is somewhere else.

We should either reject such bogosity already in the FE (e.g. C does not
allow this), or if we really want to support it, it should be genericized
differently (the string must have a fixed size, and either we allow in the
IL assignment of the fixed size array to the VLA, or it should be
genericized e.g. as memcpy from the fixed size STRING_CST to the start of
the VLA.

	Jakub



More information about the Gcc-patches mailing list