[Vm-dev] Re: [Pharo-project] new Cog VMs uploaded

Eliot Miranda eliot.miranda at gmail.com
Wed Apr 27 18:24:07 UTC 2011


Hi All,

    this is because of carelessness in the
trunk platforms/unix/plugins/LocalePlugin/sqUnixLocale.c which uses strcpy
to copy C strings from the locale subsystem into Smalltalk strings.  strcpy
copies the trailing null, which will overwrite the first byte of the
following object.  This just happens not to kill the standard VM because
current code always uses these functions on new strings.  But Cog currently
checks for attempts to overwrite objects and hence it catches these
attemptys and aborts, with an error message.

Hilaire, Phillipe, you should have seen and reported the "last object
overwritten" report form the VM and if so we would have debugged this a lot
sooner.  Error messages are there to be read.

Ian, David, I recommend that you fold

    URL:
http://www.squeakvm.org/svn/squeak/branches/Cog/platforms/unix/plugins/LocalePlugin/sqUnixLocale.c
    Revision: 2382

back into trunk.

I've replaced all uses of strcpy
in platforms/unix/plugins/LocalePlugin/sqUnixLocale.c with the following:

/* For Cog do *not* copy the trailing null since the VM checks for attempts
to
 * overwrite the end of an object, and copying the trailing null into a
string
 * does precisely this.
 */
#define safestrcpy(str,source) do { \
    char *src = (source); \
    int len = strlen(src); \
    strncpy(str,src,len); \
} while (0)



On Wed, Apr 27, 2011 at 8:18 AM, Philippe Marschall <kustos at gmx.net> wrote:

> On 26.04.2011 23:01, Eliot Miranda wrote:
> > ...to http://www.mirandabanda.org/files/Cog/VM/VM.r2379/.  These fix
> > shallowCopy and copyFrom: for contexts and (I hope) fix the linux Locale
> > plugin.
>
> The following still crashes my vm:
>
> (Locale localeID: (LocaleID isoLanguage: 'de' isoCountry: 'CH'))
> primShortDateFormat
>
> Cheers
> Philippe
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20110427/bd3f9873/attachment.htm


More information about the Vm-dev mailing list