Bug 12828 - array created with less than the specified length
Summary: array created with less than the specified length
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.9.1.x
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-06-21 18:15 UTC by reza
Modified: 2013-07-01 20:34 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description reza 2013-06-21 18:15:18 UTC
in List<double>.ToArray() and my own functions, when an array is created, it sometimes is created  too short.

My code..

T[] ret = new T[Len()];

from the debugger..

> ret
{double[259]}
> Len()
260

how does that happen?  This is on Xamarin/Monotouch 4.0.8 build 2
Comment 1 Sebastien Pouliot 2013-06-25 11:06:57 UTC
It should not* and I can't duplicate this.

* at least not if `Len` always return the same value, e.g.

int Len () { return len++; }

would produce a similar issue. Another case would be if your collection (List) has grown between the calls.


Can you extract a test case, either using List<double>.ToArray() or your own functions ? 

and show us the code for Len() ?
Comment 2 reza 2013-06-28 15:15:08 UTC
In looking over the code, Len() might have changed.   I'll add some locking code around it and test.
Comment 3 Sebastien Pouliot 2013-07-01 20:34:03 UTC
Please re-open the bug, along with a self-contained test case, if you can duplicate this.