forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix concurrency bug in ConcurrentSlab.replace. (FuelLabs#2378)
So what happens here is that we get the following panic during `ConcurrentSlab.replace` execution: ``` thread 'main' panicked at 'rwlock read lock would result in deadlock', /rustc/ddcbba036aee08f0709f98a92a342a278eae5c05/library/std/src/sys/unix/locks/pthread_rwlock.rs:72:13 ``` This happens due to `operator !=`, we call `PartialEq` and eventually end up calling `ConcurrentSlab.get`, which fails due to existing read/write lock already on the stack. The fix is to make sure to get a read lock only, do the comparison, and then get a read/write lock just for the write. Closes FuelLabs#2341.
- Loading branch information
Showing
6 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
test/src/e2e_vm_tests/test_programs/should_pass/language/contract_caller_as_ret/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[[package]] | ||
name = 'contract_caller_as_ret' | ||
source = 'root' | ||
dependencies = [ | ||
'core', | ||
'std', | ||
] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-277F468596DF2097' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-277F468596DF2097' | ||
dependencies = ['core'] |
9 changes: 9 additions & 0 deletions
9
test/src/e2e_vm_tests/test_programs/should_pass/language/contract_caller_as_ret/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
license = "Apache-2.0" | ||
name = "contract_caller_as_ret" | ||
entry = "main.sw" | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } | ||
std = { path = "../../../../../../../sway-lib-std" } |
15 changes: 15 additions & 0 deletions
15
...e_vm_tests/test_programs/should_pass/language/contract_caller_as_ret/json_abi_oracle.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"inputs": [], | ||
"name": "test_function", | ||
"outputs": [ | ||
{ | ||
"components": null, | ||
"name": "", | ||
"type": "bool", | ||
"typeArguments": null | ||
} | ||
], | ||
"type": "function" | ||
} | ||
] |
16 changes: 16 additions & 0 deletions
16
test/src/e2e_vm_tests/test_programs/should_pass/language/contract_caller_as_ret/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
contract; | ||
use std::contract_id::ContractId; | ||
|
||
abi MyContract { | ||
fn test_function() -> bool; | ||
} | ||
|
||
impl MyContract for Contract { | ||
fn test_function() -> bool { | ||
true | ||
} | ||
} | ||
|
||
fn caller(address: ContractId) -> ContractCaller<_> { | ||
abi(MyContract, address.value) | ||
} |
2 changes: 2 additions & 0 deletions
2
test/src/e2e_vm_tests/test_programs/should_pass/language/contract_caller_as_ret/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
category = "compile" | ||
validate_abi = true |