Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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
GitHub or Developer Community 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.
Created attachment 3822 [details]
Project to reproduce the bug
I enumerate dictionary via Mono embedded C API.
The dictionary is not modified, but when I call MoveNext on the enumerator - it throws:
System.InvalidOperationException: out of sync
at System.Collections.Generic.Dictionary`2+Enumerator[System.String,System.Object].VerifyState () [0x00000] in <filename unknown>:0
at System.Collections.Generic.Dictionary`2+Enumerator[System.String,System.Object].MoveNext () [0x00000] in <filename unknown>:0
This exception is only thrown when the dictionary generation differs from the enumerator stamp:
private void VerifyState ()
if (this.dictionary == null)
throw new ObjectDisposedException (null);
if (this.dictionary.generation != this.stamp)
throw new InvalidOperationException ("out of sync");
But I've checked stamp and generation - they are equal! And there is no such problem when I use old compatibility IDictionaryEnumerator.
The only difference I see is that the normal enumerator is a struct, but the old compatibility one is a class. So it's rather a some kind of JIT bug, or C API has problems calling methods on structs.
The project to reproduce the bug is attached to the issue. It's configured to build and run on default 3.0.10 installation of Mono (/Library/Frameworks/...) with Boehm GC
So, is it a bug, or am I working with the structs the wrong way?
OK, i've resolved this.
The structs have to be unboxed before method calls or undefined behavior happens.
This is not an issue anymore.