Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAR Cache should be versioned (TranslateDictionary) #6659

Closed
KirillOsenkov opened this issue Jul 8, 2021 · 1 comment · Fixed by #6674
Closed

RAR Cache should be versioned (TranslateDictionary) #6659

KirillOsenkov opened this issue Jul 8, 2021 · 1 comment · Fixed by #6674

Comments

@KirillOsenkov
Copy link
Member

I happened to be building under debugger, and saw the serialization exception in DateTime ctor (which usually signals corrupt data) when reading the state file: obj\Debug\TestSolution.csproj.AssemblyReference.cache

The .cache file is attached:
TestSolution.csproj.AssemblyReference.zip

mscorlib	DateTime..ctor Line 159
Microsoft.Build.Tasks.Core	BinaryTranslator.BinaryReadTranslator.Translate Line 330
Microsoft.Build.Tasks.Core	SystemState.FileState.Translate Line 164
Microsoft.Build.Tasks.Core	SystemState.FileState..ctor Line 154
Microsoft.Build.Tasks.Core	SystemState.<>c.<Translate>b__18_0 Line 251
Microsoft.Build.Tasks.Core	TranslatorHelpers.Translate Line 38
Microsoft.Build.Tasks.Core	TranslatorHelpers.<>c__DisplayClass1_0`1.<AdaptFactory>g__TranslateUsingValueFactory|0 Line 51
Microsoft.Build.Tasks.Core	BinaryTranslator.BinaryReadTranslator.TranslateDictionary Line 600
Microsoft.Build.Tasks.Core	TranslatorHelpers.TranslateDictionary Line 88
Microsoft.Build.Tasks.Core	SystemState.Translate Line 255
Microsoft.Build.Tasks.Core	SystemState..ctor Line 223
	[Internal Frame, 'U-->M']
mscorlib	RuntimeConstructorInfo.Invoke Line 753
mscorlib	ConstructorInfo.Invoke Line 105
Microsoft.Build.Tasks.Core	StateFileBase.DeserializeCache Line 88
Microsoft.Build.Tasks.Core	ResolveAssemblyReference.ReadStateFile Line 2006
Microsoft.Build.Tasks.Core	ResolveAssemblyReference.Execute Line 2262
Microsoft.Build.Tasks.Core	ResolveAssemblyReference.Execute Line 3150

Since there's a try catch around reading the cache, the error is benign (I think?).

But I'd be curious what happened, either the format of serialized dictionaries changed across MSBuild versions or something else.

@Forgind any ideas?

@KirillOsenkov KirillOsenkov added needs-triage Have yet to determine what bucket this goes in. Task: Resolve Assembly References (RAR) labels Jul 8, 2021
@Forgind
Copy link
Member

Forgind commented Jul 9, 2021

Yeah; we looked into this because it was preventing caches from being read.

The cache actually does have a version. What is a bug is that the version is read, then the rest is deserialized, then the version is checked, which is not a rational ordering.

Version read
Rest deserialized
Version checked

This came up with #6350. In addition to removing BF from all other StateFileBases (it had already been removed from SystemState), I combined their serialization code so they'd all go through the same path instead of having essentially just copied code.

The temporary fix is just to update the SDK used to build the SDK, since then it serializes it the same way it's expected to be serialized. I did that, and I'm planning to test that momentarily. This issue will recur, however, should the format change again, so it would be good to move the version check up.

@Forgind Forgind removed the needs-triage Have yet to determine what bucket this goes in. label Jul 14, 2021
@Forgind Forgind added this to the 17.0 milestone Jul 14, 2021
@Forgind Forgind self-assigned this Jul 14, 2021
ladipro pushed a commit that referenced this issue Jul 26, 2021
Fixes #6659

The version check was previously after having deserialized everything else. This doesn't make sense and can lead to errors. In this PR, I moved it up.
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants