[reportlab-users] pyRXP - strange non-deterministic errors on python 2.7 and 64-bit Linux

Tim Roberts timr at probo.com
Wed May 18 13:30:06 EDT 2011


Robin Becker wrote:

> OK this is the errant code in url.c

>

> p=merged_path

>

> .....

>

> fprintf(stderr," 261: merged_path=%s i=%d j=%d p[i+1]=%c\n",

> merged_path,i,j,p[i+1]);

> /* Do we have "." ? */

>

> if(j - i == 2 && p[i+1] == '.')

> {fprintf(stderr," 265: p+i+1=%s p+j=%s

> (&p[i+1]-&p[0])=%d\n", p+i+1,p+j,&p[i+1]-&p[0]);

> strcpy(&p[i+1], p[j] ? &p[j+1] : &p[j]);

> ...

> so the error appears to be in strcpy; not sure if that's rxp's fault or not any

> ideas?


A ha! NOW it makes sense!

The results of strcpy are undefined when the source and destination
overlap, as is the case here. The 32-bit implementation did what you
expected, although it was not required to. The 64-bit implementation
apparently contains optimizations that break this case. It is allowed
to do that.

The code needs to compute the length of the copy and use memmove instead
of strcpy, or do the copying in a loop.

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list