chipsalliance / chipsalliance/rocket-chip

Diplomacy is not thread safe

Open
#2,939 0 comments 1 reaction 0 assignees View on GitHub
proposal
Dominant language
Scala
Stars
3.9k
Forks
1.3k
Avg merge
5d 13m
Merged PRs (30d)
1

Description

https://github.com/chipsalliance/rocket-chip/blob/86a2f2cca699f149bcc082ef2828654a0a4e3f4b/src/main/scala/diplomacy/LazyModule.scala#L218-L224
makes Diplomacy not thread safe.
Which makes not possible to invoke multiple LazyModule inside a JVM
I'm proposing moving those variables to `DiplomacyCtx` class, but this will introduce a API change to entire codebase.

**Type of issue**: bug report

**Impact**: API modification

**Development Phase**: request

**Other information**

**If the current behavior is a bug, please provide the steps to reproduce the problem:**
Invoke `LazyModule` twice, `index` and `scope` will lead to strange behavior.

**What is the current behavior?**

**What is the expected behavior?**

**Please tell us about your environment:**

**What is the use case for changing the behavior?**

Contributor guide

Open the contributing guide

Research direction

Start at the linked LazyModule.scala lines 218-224 and inspect how index and scope behave when LazyModule is invoked twice in one JVM. Review DiplomacyCtx as the proposed location for those variables, then verify that multiple LazyModule instances no longer produce strange behavior while accounting for the stated API change.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.