ExtractionExceptions is a non-thread-safe List<string> accessed from concurrent threads

Open Beginner friendly
#152 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
csharp
Domain
desktop

Research direction

Open src/L10NSharp/XLiffUtils/XliffLocalizationManager.cs and inspect ExtractionExceptions and the AddRange calls used by ExtractStringsFromCode. Change the collection and additions as specified, then verify that concurrent calls no longer share a non-thread-safe list or corrupt exception data.

Written by the indexing model from the issue text.

Description

api change bug

ExtractionExceptions is declared as static List<string>. When ExtractStringsFromCode is called from concurrent threads, multiple threads may call AddRange on the same list simultaneously, causing data corruption.

Fix: Change ExtractionExceptions from List<string> to ConcurrentBag<string> and replace AddRange calls with individual Add calls.

Files affected: src/L10NSharp/XLiffUtils/XliffLocalizationManager.cs

(Part of #135.)

Dominant language
C#
Stars
3
Forks
10
Avg merge
4d 12h
Merged PRs (30d)
9

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sillsdev/l10nsharp

All issues in sillsdev/l10nsharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.