fluent / fluent/fluent-logger-java
Bad thread interleaving may cause unexpected crash
- Dominant language
- Java
- Stars
- 210
- Forks
- 86
- PR merge metrics
- No merged PRs in 30d
Description
Commit version - da14ec3
Describe the bug
It is possible to encounter an unexpected crash due to using the shared variable array in multiple locations (variable name is counters, in TestFluentLogger). In one place at Line 403 sets the value in this data-structure, whereas another location at Line 461 gets the value from this shared variable. However, there is no synchronization given between these accesses. As a result, anytime due to the existence of multiple threads, the program may crash.
Expected behavior
No crash is expected
Additional context
When I investigated the TestFluentLogger class, I found that the counters is a shared variable declared at Line 385 that is used at Line 403, Line 461. Here, the unexpected crash or inconsistency may occur if multiple threads interleave.
Environment:
I ran the test on an Ubuntu 20.04 LTS machine using OpenJDK 1.8.0_312.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the TestFluentLogger class at the counters declaration around line 385 and its accesses around lines 403 and 461. Reproduce or inspect the test under multiple-thread interleaving on the stated Java environment, then verify that the shared accesses no longer permit a crash or inconsistent result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100