From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id E70693857C49 for ; Wed, 27 Apr 2022 19:35:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E70693857C49 Received: by mail-oi1-x231.google.com with SMTP id m11so3071712oib.11 for ; Wed, 27 Apr 2022 12:35:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:references:in-reply-to :content-transfer-encoding; bh=yzw2xHwzFcEJPnzQORJAVKG0RCPNi85ECWkS8eOxuls=; b=FGtuFAsBstoCoEcj5ydxJzUbn8ADT0wPf5QiRgj7+efK1OFQPW8rrDCQxn0ittC1q2 tuSUIAE8rEJY1JrMazoW4kxSiNA64gTOrAO7Edlr+J1Il6GNbmuMhSqChrO7BMwgXvIg B6Q4AaZsEwRb/vfLw/z/pwqLjKrA0148g+RpVbN+iN574fmaOyvol+sOykpmiAgAZaNl NBk4wn6w2zfyNnvnt3uEcxWWUdRXpqZt46MIGlYEwXLNzICBu8TLZcJQWMlVCqXyE9Su tRb/O7QtmSwzrFYzV7VKeAeigROmIA7f174RWe1F9Eqfur+AiJZ85ADYFgQ2UWsde21o Leug== X-Gm-Message-State: AOAM533dtzWCOFgsYBXzna11K1cYlMOtwLBr79KOAr5o4A6g/0M+4X1R ENCZ7D2+0qkF59MeKTQWT4jSHqO6Hz5l2A== X-Google-Smtp-Source: ABdhPJy5/pCJCtJr0QXD5xKByWBVCg3H2dDhN+EQo1oWVRK9s9PiyV+7yyBgsYYOvgF73/ybYI0zSw== X-Received: by 2002:aca:36c1:0:b0:2ec:cf67:b8ef with SMTP id d184-20020aca36c1000000b002eccf67b8efmr17925536oia.115.1651088131110; Wed, 27 Apr 2022 12:35:31 -0700 (PDT) Received: from ?IPV6:2804:431:c7ca:4214:b613:182d:cdde:5f86? ([2804:431:c7ca:4214:b613:182d:cdde:5f86]) by smtp.gmail.com with ESMTPSA id s11-20020aca450b000000b003258387dcacsm706828oia.33.2022.04.27.12.35.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 12:35:30 -0700 (PDT) Message-ID: <61ac8832-730a-f23e-bb9f-54a79dea42cb@linaro.org> Date: Wed, 27 Apr 2022 16:35:28 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v2 1/4] libio: Assume _IO_MTSAFE_IO Content-Language: en-US From: Adhemerval Zanella To: Florian Weimer , Adhemerval Zanella via Libc-alpha References: <20220426191523.833171-1-adhemerval.zanella@linaro.org> <20220426191523.833171-2-adhemerval.zanella@linaro.org> <87wnfahfhb.fsf@oldenburg.str.redhat.com> <56a48e5d-60e3-fa95-1fef-e2a74bb76752@linaro.org> In-Reply-To: <56a48e5d-60e3-fa95-1fef-e2a74bb76752@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2022 19:35:34 -0000 On 27/04/2022 15:40, Adhemerval Zanella wrote: > > > On 27/04/2022 09:34, Florian Weimer wrote: >> * Adhemerval Zanella via Libc-alpha: >> >>> It is already set by default on all supported architectures and it is >>> an expectation that stdio works on multi-threaded environments. >> >> So … this cleanup has got stuck in the past because it's actually more >> than just a cleanup. We actually build most of glibc without libio >> locking. Looks like misc/ nss/ posix/ have not been covered before. >> >> Maybe we should just file a bug for the missing locking and fix this >> with this commit? > > It seems a better approach, I will check which files as missing support > and open a bug report. > >> >>> index 5af476c48b..c186375c31 100644 >>> --- a/sysdeps/nptl/libc-lock.h >>> +++ b/sysdeps/nptl/libc-lock.h >>> @@ -25,7 +25,7 @@ >>> >>> >>> /* Mutex type. */ >>> -#if defined _LIBC || defined _IO_MTSAFE_IO >>> +#if defined _LIBC >>> # if (!IS_IN (libc) && !IS_IN (libpthread)) || !defined _LIBC >>> typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t; >>> # else >> >> This doesn't look quite right. Would we want to compile this >> unconditionally now? > > Afaiu using __libc_lock_recursive without _IO_MTSAFE_IO will resulting > in using __libc_lock_recursive_opaque__, which will result in a undefined > type. > > Also, I really think we should not tie stdio code with general lock > primitives (as _IO_MTSAFE_IO is doing here). > >> >> There's also some weirdness I can't explain. I get strange before/after >> symbol differences: >> >> DIFF eu-readelf -s after strip: nptl/pthread_rwlock_unlock.os >> --- /tmp/Left-ltjeu50v.o 2022-04-27 14:29:39.070599437 +0200 >> +++ /tmp/Right-jee20kfm.o 2022-04-27 14:29:39.074599395 +0200 >> @@ -1,5 +1,5 @@ >> >> -Symbol table [11] '.symtab' contains 14 entries: >> +Symbol table [11] '.symtab' contains 13 entries: >> 4 local symbols String table: [12] '.strtab' >> Num: Value Size Type Bind Vis Ndx Name >> 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF >> @@ -12,7 +12,6 @@ >> 7: 0000000000000000 463 FUNC GLOBAL DEFAULT 1 ___pthread_rwlock_unlo> >> 8: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UNDEF __GI___libc_fatal >> 9: 0000000000000000 463 FUNC GLOBAL DEFAULT 1 __GI___pthread_rwlock_> >> - 10: 0000000000000000 463 FUNC GLOBAL DEFAULT 1 __pthread_rwlock_unlock >> - 11: 0000000000000000 463 FUNC GLOBAL DEFAULT 1 __pthread_rwlock_unloc> >> - 12: 0000000000000000 463 FUNC GLOBAL DEFAULT 1 pthread_rwlock_unlock@> >> - 13: 0000000000000000 463 FUNC GLOBAL DEFAULT 1 pthread_rwlock_unlock@> >> + 10: 0000000000000000 463 FUNC GLOBAL DEFAULT 1 __pthread_rwlock_unloc> >> + 11: 0000000000000000 463 FUNC GLOBAL DEFAULT 1 pthread_rwlock_unlock@> >> + 12: 0000000000000000 463 FUNC GLOBAL DEFAULT 1 pthread_rwlock_unlock@> >> >> Can you reproduce this? > > I didn't check the symbol generation, I will take a look. I think it might be from: diff --git a/include/stdio.h b/include/stdio.h index 23b7fd288c..e9a7c77c24 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -1,5 +1,5 @@ #ifndef _STDIO_H -# if !defined _ISOMAC && defined _IO_MTSAFE_IO +# if !defined _ISOMAC # include # endif Where tt now pulls libc-lockP.h from from libc-lock.h. And libc-lockP.h contains a lot of duplicated definition already preseted on pthreadP.h, and worse, it it defined some hidden_proto not presented in pthreadP.h. I will send a patch to consolidate this definitions prior the one that removes _IO_MTSAFE_IO.