[Mono-list] Some bugs on Mono.DataConverter

Luis Gomes lmagomes at gmail.com
Thu May 31 04:10:30 EDT 2007


Hello Miguel,


On 5/30/07, Miguel de Icaza <miguel at novell.com> wrote:
> Hello Luis,
>
>     Thanks for the patches and fixes
>
> > On line 1229/1230 and 1239/1240 on PutBytesLE and PutBytesBE:
> > for (; i < count; i++)
> >       dest [i-count] = *src++;
> >
> > This starts putting data on an address that does not belong to the
> > pointer (a negative value), crashes mono (on Linux), and makes it
> > return a wrong value on Microsoft .net 2.0.
> >
> > I changed it to:
> > dest = &dest [count-1];
> > for (; i < count; i++)
> >       *dest-- = *src++;
>
> I changed this to:
>
>         dest += count;
>         for (; i < count; i++)
>                 *(--dest) = *src++;
>
>

Fine by me :)

> > It doesn't compile on Microsoft .net 2.0 because of the definition of
> > the var n inside the switch statements on lines 482 and 708
>
> This seems very odd, that sounds like a bug in the Microsoft compiler.
> I have added a workaround.
>
> > , and
> > "fixed (byte* target = (&dest[destIdx]))" on line 974.
> >
> > The last error goes away if you use "fixed (byte* target =
> > &dest[destIdx])" like it is used in the other overloaded PutBytes
> > methods, and I don't see any problem with that.
>
> Am perplexed about this one as well, what was the error that you got?
>
> I fixed it to be like the others, but am interested in knowing if we
> have to modify our compiler.
>

Compiled with visual studio 2005
(C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig
/unsafe+ /nowarn:1701,1702 /errorreport:prompt /warn:4
/define:TRACE;DEBUG;MONO_DATACONVERTER_PUBLIC;MONO_DATACONVERTER_STATIC_METHODS
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
/debug+ /debug:full /optimize- /out:obj\Debug\Mono.DataConverter.dll
/target:library DataConverter.cs Properties\AssemblyInfo.cs)

Here are the errors:

DataConverter.cs(482,25): error CS0136: A local variable named 'n'
cannot be declared in this scope because it would give a different
meaning to 'n', which is already used in a 'child' scope to denote
something else
( more here: http://msdn2.microsoft.com/en-us/library/973aa6bt(VS.80).aspx )


DataConverter.cs(974,40): error CS0212: You can only take the address
of an unfixed expression inside of a fixed statement initializer
( more here: http://msdn2.microsoft.com/en-us/library/29ak9b70(VS.80).aspx )

> > Any problems on having the XXXFromXE (byte [] data, int index) methods
> > overloaded with an index of always 0? I'm not sure if there is a good
> > reason for it not being there, but if there is none, and you are OK
> > with it, I can also do it and submit a patch.
>
> The only reason I did not do this is that they kind of bloat the API,
> but since it is a conditional define, I have no problem including them
> if you want to send a patch.
>
> Please also provide the text to include in the documentation for the
> Wiki page.
>

That's a good point, since it adds around 40 new methods... I'll see
how it looks and submit a patch.

> Miguel.
>


More information about the Mono-list mailing list