Skip to content

Broken double-checked locking (data race) in RazorDocumentServiceProviderWrapper #58004

@chselab

Description

@chselab

Version Used:
dac98b9 (latest commit on the main branch as of this writing), the most recent commit to the document is 0e94007

Steps to Reproduce:
The code of RazorDocumentServiceProviderWrapper is formally incorrect in terms of parallelism. It applies the double-checked locking pattern without marking the respective fields as volatile.

Expected Behavior:
One possible solution is marking the fields _spanMappingService, _excerptService, and _documentPropertiesService as volatile to conform to C#'s memory-model.

Actual Behavior:
Formally incorrect, see Exploring the Singleton Design Pattern (docs.microsoft.com)

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions