FS#59245 - [erlang] [erlang-nox] race condition when generating async operation ids

Attached to Project: Community Packages
Opened by Roy Zuo (roylez) - Friday, 06 July 2018, 00:16 GMT
Last edited by Evangelos Foutras (foutrelis) - Wednesday, 11 July 2018, 00:42 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Alexander F. Rødseth (xyproto)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

The counter used for generating async operation ids was a plain int
shared between all ports, which was incorrect but mostly worked
fine since the ids only had to be unique on a per-port basis.
However, some compilers (notably GCC 8.1.1) generated code that
assumed that this value didn't change between reads. Using a
shortened version of enq_async_w_tmo as an example:

int id = async_ref++;
op->id = id; //A
return id; //B

In GCC 7 and earlier, `async_ref` would be read once and assigned
to `id` before being incremented, which kept the values at A and B
consistent. In GCC 8, `async_ref` was read when assigned at A and
read again at B, and then incremented, which made them inconsistent
if we raced with another port.

The issue is fixed upstream in 21.0.2.

Additional info:
* package version(s)

erlang 21.0.1-*
erlang-nox 21.0.1-*

* config and/or log files etc.

nil

Steps to reproduce:

references:

[1]: https://github.com/elixir-ecto/db_connection/issues/127
[2]: https://github.com/jhogberg/otp/commit/e27b98b353df6b4d02d0180fd6ffa86519b41917
This task depends upon

Closed by  Evangelos Foutras (foutrelis)
Wednesday, 11 July 2018, 00:42 GMT
Reason for closing:  Fixed
Additional comments about closing:  Bumped both packages to 21.0.2.

Loading...