Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New warnings: warning: unused function 'ensure_shared_on_read' [-Wunused-function] #116029

Closed
Eclips4 opened this issue Feb 28, 2024 · 3 comments
Closed
Labels
topic-free-threading type-bug An unexpected behavior, bug, or error

Comments

@Eclips4
Copy link
Member

Eclips4 commented Feb 28, 2024

Bug report

Bug description:

Popped up during the build (./configure --with-pydebug && make -j):

Objects/dictobject.c:1233:1: warning: unused function 'ensure_shared_on_read' [-Wunused-function]
ensure_shared_on_read(PyDictObject *mp)
^
In file included from Objects/obmalloc.c:16:
In file included from Objects/mimalloc/static.c:23:
Objects/mimalloc/alloc.c:77:5: warning: static function 'mi_debug_fill' is used in an inline function with external linkage [-Wstatic-in-inline]
mi_debug_fill(page, block, MI_DEBUG_UNINIT, mi_page_usable_block_size(page));
^
Objects/mimalloc/alloc.c:30:13: note: 'mi_debug_fill' declared here
static void mi_debug_fill(mi_page_t* page, mi_block_t* block, int c, size_t size) {
...
Objects/dictobject.c:5032:9: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
    if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) {
        ^                                                    ~~
Objects/dictobject.c:5032:9: note: add parentheses after the '!' to evaluate the comparison first
    if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) {
        ^
         (                                                       )
Objects/dictobject.c:5032:9: note: add parentheses around left hand side expression to silence this warning
    if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) {
        ^
        (                                                   )
Objects/dictobject.c:5155:9: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
    if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) {
        ^                                                    ~~
Objects/dictobject.c:5155:9: note: add parentheses after the '!' to evaluate the comparison first
    if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) {
        ^
         (                                                       )
Objects/dictobject.c:5155:9: note: add parentheses around left hand side expression to silence this warning
    if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) {
        ^

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

@Eclips4 Eclips4 added the type-bug An unexpected behavior, bug, or error label Feb 28, 2024
@Eclips4 Eclips4 changed the title New warning: warning: unused function 'ensure_shared_on_read' [-Wunused-function New warning: warning: unused function 'ensure_shared_on_read' [-Wunused-function] Feb 28, 2024
@Eclips4 Eclips4 changed the title New warning: warning: unused function 'ensure_shared_on_read' [-Wunused-function] New warnings: warning: unused function 'ensure_shared_on_read' [-Wunused-function] Feb 28, 2024
@colesbury
Copy link
Contributor

@sobolevn
Copy link
Member

sobolevn commented Mar 4, 2024

Since this function looks like this:

static inline void
ensure_shared_on_read(PyDictObject *mp)
{
#ifdef Py_GIL_DISABLED
    if (!_Py_IsOwnedByCurrentThread((PyObject *)mp) && !IS_DICT_SHARED(mp)) {
        // The first time we access a dict from a non-owning thread we mark it
        // as shared. This ensures that a concurrent resize operation will
        // delay freeing the old keys or values using QSBR, which is necessary
        // to safely allow concurrent reads without locking...
        Py_BEGIN_CRITICAL_SECTION(mp);
        if (!IS_DICT_SHARED(mp)) {
            SET_DICT_SHARED(mp);
        }
        Py_END_CRITICAL_SECTION();
    }
#endif
}

I am going to cc @colesbury

@sobolevn
Copy link
Member

sobolevn commented Mar 4, 2024

@colesbury it was fast 😆

I still see this on the latest main:

Objects/dictobject.c:1242:1: warning: unused function 'ensure_shared_on_read' [-Wunused-function]
ensure_shared_on_read(PyDictObject *mp)
^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-free-threading type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants