This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc addresssanitizer in MIPS


Hi Yury, try to use the patch for asan.c to see if it solve your problem.

pinskia, thank you. I compiled asan with libssp which mean the stack grows down.
I disassembled the compiled code and debuged the bin time to time
before I thought it was a bug.early this month.
I tried GCC 4.8.1 and GCC 4.9 snapshot 20130930.
Moreover I never see this problem when I use GCC 4.8 i386.

My test was to use attached time.cpp for asan test. And I found the
shadow memory was not cleared for variable tim (shadow memory address
range 0x2ea1f783-0x2ea1f788) and a strange "f4" lived in it.

  0x2ea1f730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x2ea1f740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x2ea1f750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x2ea1f760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1
  0x2ea1f770: f1 f1 f1 04 f4 f4 f4 f2 f2 f2 f2 00 04 f4 f4 f2
=>0x2ea1f780: f2 f2 f2[00]00 00 f4 00 04 f4 f4 f3 f3 f3 f3 00
  0x2ea1f790: 00 00 00 00 00 00 f1 f1 f1 f1 04 f4 f4 f4 f2 f2
  0x2ea1f7a0: f2 f2 00 00 00 00 f2 f2 f2 f2 00 00 00 00 00 00
  0x2ea1f7b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x2ea1f7c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x2ea1f7d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

2013/10/29 Yury Gribov <y.gribov@samsung.com>:
>> Yes, we do see this error on ARM.
>
> Here is another instance of the same bug:
> http://permalink.gmane.org/gmane.comp.debugging.address-sanitizer/531
>
>
>> Full description and suggested patch are available at
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58543
>> I'm curious whether suggested patch is going to work for Andrew.
>
> -Y
>
>
>
#include <stdio.h>
#include <time.h>
#include <sys/timeb.h>

static int GetDataAndTimeString(char* pszTime,unsigned int nLen)
{
	if ( NULL != pszTime )
	{
		time_t	 b_time;
		struct	 tm   tim;
		b_time=time(NULL);
		localtime_r(&b_time, &tim);
		
		struct timeb timebuffer;  
		ftime( &timebuffer );  

		snprintf(pszTime,nLen,"%d/%02d/%02d %02d:%02d:%02d.%03d",
				 tim.tm_year+1900,tim.tm_mon+1,tim.tm_mday,
				 tim.tm_hour,tim.tm_min,tim.tm_sec,timebuffer.millitm);
		return 0;
	}
	return -1;
}

int main()
{
	char szDate[32] = {0};
    GetDataAndTimeString(szDate,sizeof(szDate));
	return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]