From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id A3F8E2D01B for ; Fri, 30 Aug 2024 15:35:19 +0200 (CEST) Received: (qmail 7848 invoked by uid 550); 30 Aug 2024 13:35:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7771 invoked from network); 30 Aug 2024 13:35:14 -0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FBb9fYtRGxvZKQ/mKjQHRixIzjpceTgrlCTcgdJ0d9OyZjcdxY0Upnri3ZoLksKaeAmw5QfTGbUwcQzaoUDnz7g2510llJEoU2oHoSQaGn8mSBgAa5NEcARarO5FXtVwu5iE/fISKzUDOO6kIZELiWI2RY4sWNyVt1eUNY1uloCss3fy+Hwv/67hpY5vmYT92KwlXS2Kbd/ymhygrM1gOMFXVa4BRrUV38pWgVMyAGPBmd+MmBgVItC5zXRdAnWzo4b0UhBP9lxOKByqkdMqPB9PXtRSwRR3FNEAd2FN7HglKvSnS8xy/bln7nj1NWYQjiugQqyATdsr271RxaeZ0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kWSakzRpdXs88rshZtbr4eKYwr6cI6zQoQEkwlgWqgM=; b=nmR1IA2VW/Lptqx9sgQk7kYQNEJIBRqVM9H1JpcAZqLH4/4X2zRTXdv65/8J5VZFmiYgwSYWRQpzVJxX5Tn0c7VsqUZLCF38wWDecM4TI9j7EoAJx/Ht3D/glT8ooDPf3jKhfJQ71a8jYlS+4aN2M7bQjG+2pDtRyIvs10fRvG9u35FIFgxqz92Hvvb/YiOjhLEA8bX8NT+umWZQRfuyBxh/qNV/bzdf1Yqqnu+ZwtZdQ4bTchnZoO1CWMXT7IYn3sFcaDVM+TnUoSo7w/qs/NTmaYUL1W+4MxAutrMzln4Zi0D0qpv6skjB8yap/KvIhL3NxF5nIPUTexhdKsOF8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kWSakzRpdXs88rshZtbr4eKYwr6cI6zQoQEkwlgWqgM=; b=mN42cgS338WF0WbwVqtPODiiUZO7bewBh+SI3+qjGxvY1gnImCG7cuJodrOJ6n6w4MDQwCGCUO3DDkJrackzOFLSwj8jkfBuM/vcCdnEoIC0RLtlpPGh9jDAayqnD8nkHrgrW042s7H7sgPOBnG4vQ3msyQj5JIe7rvmqn7wMEeO8GmD+5ZOD2rzt+zFSo0Ei351JckLlkz23H/L5fGYRvi0PoEBwumxSj2/TsOTBWNuhM6TMp3xWvCel/T/FDus6R/Q+yvMeMDDiYPYE/BPEQ16qvlN26DLN+xXDrrf6UN8RUubEarif25cyREpSVp6fzEtNwn1LhyBT6VWy8Go4A== From: JinCheng Li To: musl Thread-Topic: Question about the exit() Thread-Index: AQHa+t7grvDRASFXl02W0Qu7dVQrEQ== Date: Fri, 30 Aug 2024 13:34:58 +0000 Message-ID: Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-tmn: [a5myWiLLS0Pn7ScCHjjcVAJq3kDo00W1] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SE1P216MB2484:EE_|PU4P216MB1307:EE_ x-ms-office365-filtering-correlation-id: 3024a941-a6ff-4c81-b99e-08dcc8f88af6 x-microsoft-antispam: BCL:0;ARA:14566002|8060799006|461199028|19110799003|15030799003|15080799006|3430499032|3412199025|440099028|102099032; x-microsoft-antispam-message-info: F7ooLKEftUgnI3wGxfqx2pbU3J/ElHjCg73l9bkPVNtFrtp5V1x7VsufJfuLaxuTktPGfXvpFC/6yPkkg58D/ps3gi0kp2pUXDAHDE8v0wFJqXfkPBbN1JvzFpvDrI1Xgd+W4LMs0i0d0tE1EGhF5rasGiQ6sA8u3iTpZQ9lxrZgCm0YawrRaQYWhAHoJcRHRkFgXlnnnMm8V18FdN8za+cO158hUwiZGOFFsi18Of186GO1UPxWR28zmVOEN48wfMYKecdvN6XY0Io3VWcjGRrC40hMdkvmrbG9W5EcsvEwDhog6TFH64+PGfroyah2lZ/B8L7r38xHIZpPok7O3N6e1HOrbYfO/TxJOzWJ3xd0n4yoIRMVouHJRRq27nJKN4E/QIw2X25no1rj3m74j1PsReAukqAp9T3rmUllb0LVFVwcEf4oM3hdQ8Z2SZX5xSxf/BobnL6p06VngJaeekoE5Dd9AnIqNCJlo16WAmCUAv2CbjjLmMF5cLFlgGn3TYcPNZhxxyOncntS858vNAg6WXcH8goym4o5TWL424Wvv3ZU/ZmcszV1epkbPK+ubhCOsZwDiMUfpN0SkZ2bG2BM75Deg89I4Fgm26IM2H3ecvnSh6cJmUF8Y20+Rll/oGiN/66jTZkdY9wkAw2zs8g06HSbPjTDh9WbLlYEgI/2P9URMM5DUr46VTpJoXgKbBvCD+PycdtWUplR6ye4Eg== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?Qf3uaduR7lG8gkhmLuZppogxLp2fQjO5cz0OM5mzwEiOekPsmbVsBytNW1?= =?iso-8859-1?Q?0BhEzVddgwcuLmB53U4OQ4U9aAp+DECDnqLM2zrZFYkBsvTUlTv5WLrvsx?= =?iso-8859-1?Q?zRafrjumnIRkqaQUr9sgLxKiFtrbivfd6MkgGljNytFCneSQ1QGpgxVB1L?= =?iso-8859-1?Q?vQn1cXBBAlSkFOGOE6RAii+O0T8AmKIjsOArUIELKvtnXE9hFCSInBg3aS?= =?iso-8859-1?Q?pk1amSTCqBWdb/vRbpxGOTtnlu6rMwCUfR5rv2t+9qOwAF/q/z8c6o2Zni?= =?iso-8859-1?Q?9VkAvkf7CVyjRBgmFNGb/rsrthLOWap7LfRiHjpC6ESL++4z3kvB1hbYmh?= =?iso-8859-1?Q?prTs94BP9CJg7R0fN73ZI9C+QTx+pVQmctHKPBXHqm790/DxF/WnPonl7J?= =?iso-8859-1?Q?gnXAAZIUVtZh4fZBJ7Lsnpp5j5iURyUKEZEFubs0n0nkeb4oGph2rQzWbz?= =?iso-8859-1?Q?mvvAIruz1vetyuXdRihhxmY4TlXBcd3yHLMOkJkowukkyLuP3/2Ub51wR3?= =?iso-8859-1?Q?3+Ilq0lB2D9W9Z9r2alzdqYVYtXa5rfPhshBEIxnBo4v4Y5aI5IMhrj28e?= =?iso-8859-1?Q?JbW+JIj6ZVDMb4+icCYeYTvz3JmePUrA7Ygy+/aLI3yZBcXd1LDBeUXjMj?= =?iso-8859-1?Q?c4JjBJ6XH26Xvm8BRa1QLGh7Qj2bJFgEicp7UjWwqsFoptv4jy74BKfA8O?= =?iso-8859-1?Q?cSAAZafBse0clxRSN1PcGyIK0DMYwfIsnR5fk5ObSWzefEdYn3XvR9Pz+i?= =?iso-8859-1?Q?KVAKdJdfxu0zprU0Rcv0kFajlhC+TpXRiKJ6sEKxMcCFz81T6biQ0PkCBk?= =?iso-8859-1?Q?euWdyvv5svQDcU0x7WZW9Zxg52EkS8gdt6dJtemRddJVxdUzlSV7eabovq?= =?iso-8859-1?Q?wq0M1JgJU6E36IBYw0/DrvnW3U0sF7A9pEjimtYnPdVVDXcArWA8rcflWx?= =?iso-8859-1?Q?91iL1yoPc8UfJ8LaQAigPIYn2OzAL6f1txkZVhiq1Kw7HNrwtu4D1sgUr/?= =?iso-8859-1?Q?e0wIs+ZwrjxrpTgcgsa1VJ7Z+iWlJGgxF6cfS4mxBGO2JNqm0/R4M5za0T?= =?iso-8859-1?Q?wYPzTWB7QKDQk3oP/+FQ+dLhUSeCQjhmHelVjFDG0FAvxZe2hJyWcjQyK2?= =?iso-8859-1?Q?4kjo1fikr0qClGC2DXIQjLU6xHmFPKnzYZCb4EQQIiZqnfjnjxnQwHY3rZ?= =?iso-8859-1?Q?INFmcXo1bHoouYGmkrjl8XNnPeTl0e73vnziBdS/5CzwW7KsQm2S6bINrs?= =?iso-8859-1?Q?nfHi1mGjcgYVeH05CFE4HnTF9aA403dNcpcfeFwAY=3D?= Content-Type: multipart/alternative; boundary="_000_SE1P216MB24840DB4017D42E4B93198C59E972SE1P216MB2484KORP_" MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB2484.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 3024a941-a6ff-4c81-b99e-08dcc8f88af6 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Aug 2024 13:34:58.8102 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU4P216MB1307 Subject: [musl] Question about the exit() --_000_SE1P216MB24840DB4017D42E4B93198C59E972SE1P216MB2484KORP_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi I have one question in exit(). Why is the __libc_exit_fini executed after __funcs_on_exit? If some finali= zed functions in .fini_array access global variables which is registered by= __cxa_atexit and will be release in __funcs_on_exit, we may run into some = crash during __libc_exit_fini executaion. _Noreturn void exit(int code) { __funcs_on_exit(); __libc_exit_fini(); __stdio_exit(); _Exit(code); } In bionic, I found the fini_array functions may be registered at the last b= efore we execute main function and called firstly in exit(before global var= iables release) . Its order looks like completely opposite to musl. __noreturn void __libc_init(void* raw_args, void (*onexit)(void) __unused, int (*slingshot)(int, char**, char**), structors_array_t const * const structors) { ...... if (structors->fini_array) { __cxa_atexit(__libc_fini,structors->fini_array,nullptr); } ...... exit(slingshot(args.argc - __libc_shared_globals()->initial_linker_arg_cou= nt, args.argv + __libc_shared_globals()->initial_linker_arg_cou= nt, args.envp)); } Best Li --_000_SE1P216MB24840DB4017D42E4B93198C59E972SE1P216MB2484KORP_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi

I have one question in exit().
Why is the __libc_exit_fini executed after __funcs_on_exit?  If some f= inalized functions in .fini_array access global variables which is reg= istered by __cxa_atexit and will be release in __funcs_on_exit, we may run = into some crash during __libc_exit_fini executaion.

_Noreturn void exit(int code)
{
    __funcs_on_exit();
    __libc_exit_fini();
    __stdio_exit();
    _Exit(code);
}


In bionic, I found the fini_array functions may be registered at = the last before we execute main function and called firstly in exit(before = global variables release) . Its order looks like completely opposite to mus= l.

__noreturn void __libc_init(void* = raw_args,
                     = ;      void (*onexit)(void) __unused,
                     = ;      int (*slingshot)(int, char**, char**),
                     = ;      structors_array_t const * const structors) {
......
 if (structors->fini_array) {
   __cxa_atexit(__libc_fini,structors->fini_array,nullptr);
 }
......
 exit(slingshot(args.argc - __libc_shared_globals()->initial_linker= _arg_count,
                args.argv + __libc_= shared_globals()->initial_linker_arg_count,
                args.envp));
}

Best
Li

--_000_SE1P216MB24840DB4017D42E4B93198C59E972SE1P216MB2484KORP_--