NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: firefox52 core dump on RPI2 NetBSD9.1



On Sat, Nov 28, 2020 at 09:15:15AM +0100, tlaronde%polynum.com@localhost wrote:
> It is also caused by knowledge of C: one imagine that strcpy is
> implemented doing _string_ manipulation (because of its name) and what one
> will do programming it directly that is:
> 
> p = buf;
> q = buf + positive_shift;
> while ((*p++ = *q++) != '\0')
> 	;

If you had written it that way, it would still work. If you use strcpy()
you are out of luck, as the contract for that function allows some 
optimizations that *will* break *sometimes* when you do overlapping copies.

Basically you can (and it sometimes is worth) to split the copy into multiple
parts where the main part of the copy is done in bigger size than single
characters (which often are extemely expensive on some architectures, to
the extreme in for example early alpha models where they were simply not
available, you always had to read the full word and mask+shift to get a
character).

Martin


Home | Main Index | Thread Index | Old Index