Skip to content

Commit

Permalink
Oops, avoid deadlock.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Nov 11, 2020
1 parent 4df5242 commit de01477
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Python backend now disables spurious NumPy overflow warnings for
both library and binary code (#1180).

* Undid deadlocking over-synchronisation for freeing opaque objects.

## [0.18.2]

### Added
Expand Down
6 changes: 3 additions & 3 deletions libtests/c/a.fut
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ type s = i32

entry a (x: s) : s = x + 2

type t1 = {x:i32}
type t1 = {x:[1]i32}
type t2 = t1

entry b (x: i32) : t1 = {x=x + 3}
entry b (x: i32) : t1 = {x=[x + 3]}

entry c : t1 -> t2 = id

entry d ({x}: t2) : i32 = x
entry d ({x}: t2) : i32 = x[0]
7 changes: 4 additions & 3 deletions src/Futhark/CodeGen/Backends/GenericC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,13 +1053,14 @@ opaqueLibraryFunctions desc vds = do
(OpaqueDecl desc)
[C.cedecl|int $id:free_opaque($ty:ctx_ty *ctx, $ty:opaque_type *obj);|]

ops <- asks envOperations

-- We do not need to enclose the body in a critical section, because
-- when we free the components of the opaque, we are calling public
-- API functions that do their own locking.
return
[C.cunit|
int $id:free_opaque($ty:ctx_ty *ctx, $ty:opaque_type *obj) {
int ret = 0, tmp;
$items:(criticalSection ops free_body)
$items:free_body
free(obj);
return ret;
}
Expand Down

0 comments on commit de01477

Please sign in to comment.