This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tzickel
Recipients tzickel
Date 2020-03-16.06:01:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1584338520.98.0.250313296967.issue39974@roundup.psfhosted.org>
In-reply-to
Content
bpo 36051 added optimization to release GIL on certain conditions of bytes joining, but it has missed a critical path.

If the number of items joining is less or equal to NB_STATIC_BUFFERS (10) than static_buffers will be used to hold the buffers.

https://github.com/python/cpython/blob/5b66ec166b81c8a77286da2c0d17be3579c3069a/Objects/stringlib/join.h#L54

But then the decision to release the GIL or not (drop_gil) does not take this into consideration, and the GIL might be released and then another thread is free to do the same code path, and hijack the static_buffers for it's own usage, causing a race condition.

A decision should be made if it's worth for the optimization to not use the static buffers in this case (although it's an early part of the code...) or not drop the GIL anyhow if it's static buffers (a thing which might make this optimization not worth it, since based on length of data to join, and not number of items to join).
History
Date User Action Args
2020-03-16 06:02:01tzickelsetrecipients: + tzickel
2020-03-16 06:02:00tzickelsetmessageid: <1584338520.98.0.250313296967.issue39974@roundup.psfhosted.org>
2020-03-16 06:02:00tzickellinkissue39974 messages
2020-03-16 06:01:59tzickelcreate