Bug 16788 - Thread.GetNamedDataSlot incorrectly increments the slot id for each call
Summary: Thread.GetNamedDataSlot incorrectly increments the slot id for each call
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 3.2.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2013-12-13 17:44 UTC by Mike Coker
Modified: 2014-01-01 09:30 UTC (History)
4 users (show)

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


Attachments
patch (504 bytes, patch)
2013-12-15 18:50 UTC, Sergey Zhukov
Details


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 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.

Related Links:
Status:
RESOLVED FIXED

Description Mike Coker 2013-12-13 17:44:49 UTC
This only seems to be broken in 3.2.X and works correctly in 2.10.X. 

If you create a simple test like this:

System.LocalDataStoreSlot slot = Thread.GetNamedDataSlot("mydata");
slot = Thread.GetNamedDataSlot("mydata");
slot = Thread.GetNamedDataSlot("mydata");

Take a look at the slot id internal to the slot and you will notice that it is incrementing, rather than finding the same id each time after the initial creation. This causes subsequent lookups to fail to find the data you store on the thread. 
I noticed that there was a refactor of the namedslot code to put this into its own object around 3.2, but I cannot tell if that is what broke it. If I can get mono building locally, I'll try to debug the issue.

For me, this is a critical issue because I'm passing important data to a thread that is getting lost. I'm having to use 2.10 until this issue is resolved.
Comment 1 Sergey Zhukov 2013-12-15 18:50:38 UTC
Created attachment 5666 [details]
patch

Here the patch for you.
Comment 2 Mike Coker 2013-12-16 10:12:28 UTC
thanks!
Comment 3 Miguel de Icaza [MSFT] 2013-12-25 20:37:00 UTC
Paolo/Rodrigo, can you guys review this?
Comment 4 Marek Safar 2014-01-01 09:30:55 UTC
Fixed in master