From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18551 invoked from network); 31 Mar 2023 02:43:58 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 31 Mar 2023 02:43:58 -0000 Received: (qmail 11877 invoked by uid 550); 31 Mar 2023 02:43:55 -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 11845 invoked from network); 31 Mar 2023 02:43:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680230623; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=AYXhpQdLsuy15RCnmplSghIKLcU7F2EQGhfsyezNCAk=; b=W5NsWqFXext+yRU2EiJwqVjtH7qM7gSAcrXbPfb3T1bQpbFgpgc7Yy7sr3K3sFHPCe ou8Z3c3cJeYBeqY6RCiKJaHVq7WT2oLDo5hQ0QvBFmnESrae+eycvSUCmbwQWAndfUVE hDJWdb/bTvqIkWBicgIf95Qg4BqL0+tHuwne2xj/QenRuTXrow2Eqakeu+MWhCS0Fswb +D3VmmRLyqEqfi5quJgFhodVKtJr4mjRQQa7shfAcHcd0IcdrsAuuTZUJpeAQqYiMsTo oS38rBuSNMw0j8OmMvlltLmz+RyGE733Or6mBFdh1Pqd/aqZsy9QY1xkxlF8MUrBVVnX DuPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680230623; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AYXhpQdLsuy15RCnmplSghIKLcU7F2EQGhfsyezNCAk=; b=2M8+itNbEsypz6Rf4K/dxw74hOCvl3K5aXQa5auv23fp6p4+msUyT4JNZE1zvnhLfL TXUG7vsMCMALi5xHbjhMmmZvoy72Ty5kTw46gvPhhKZr5Y/EzxDFyWm7T/n2PK2gsm9q VG/3nzP3Epuasc+DesB+jR/5N4gFn7PhMbavAvQHpQz9AYvXIW3cNLMMsIGJ15RO71Wi nv5guV+k8oLfMim0mDjPZFJ3FRUhhuqkPNpwmklncmTlysnPcArUicnODbOmWViyPqSi P8QsKSx9npy1AasFKrQ8MtngVQ7xUeo4C4CkZCT0oUzJem97POMaWxgkH9ElguVzvnyn 42/Q== X-Gm-Message-State: AAQBX9ckTyUtcux8I6lcWHttWyWg0ADgFb77QCF2bbO59BginY9naN7X rTC0wkSehokU4y9W01AoXUL4WraqfSYyoQGhdlAOU8wmTGk= X-Google-Smtp-Source: AKy350YTeQzDLnNYz+wqEGUD2QaWWe04VQ+YkkucOWUS3VAmlODOIoApHzWSDeQcdh/835L2OG0naStAXLbsOxNcLo0= X-Received: by 2002:a2e:a556:0:b0:29b:d43f:f68f with SMTP id e22-20020a2ea556000000b0029bd43ff68fmr4165999ljn.5.1680230622650; Thu, 30 Mar 2023 19:43:42 -0700 (PDT) MIME-Version: 1.0 From: Matt Wozniski Date: Thu, 30 Mar 2023 22:43:28 -0400 Message-ID: To: musl@lists.openwall.com Content-Type: text/plain; charset="UTF-8" Subject: [musl] Unwinding multithreaded musl applications with elfutils fails I'm unsure if this is an elfutils bug or a musl bug. I suspect both. I've already reported this to the elfutils maintainers at https://sourceware.org/bugzilla/show_bug.cgi?id=30272 Using the elfutils eu-stack program or libdw's dwfl_getthread_frames API to unwind multithreaded applications linked against musl libc on x86-64 fails, getting stuck on `__clone`: TID 241: #20 0x00007f6f2f74f08b start #21 0x00007f6f2f75138e __clone #22 0x00007f6f2f75138e __clone #23 0x00007f6f2f75138e __clone ... #253 0x00007f6f2f75138e __clone #254 0x00007f6f2f75138e __clone #255 0x00007f6f2f75138e __clone eu-stack: tid 241: shown max number of frames (256, use -n 0 for unlimited) GDB seems to detect the condition that libdw is getting stuck on, emitting a warning message but terminating: #44 0x00007f8f83e4d08b in start (p=0x7f8f836b8b00) at src/thread/pthread_create.c:203 #45 0x00007f8f83e4f38e in __clone () at src/thread/x86_64/clone.s:22 Backtrace stopped: frame did not save the PC I suspect the cause for gdb's "frame did not save the PC" warning and elfutils' repeated emission of the same frame is an invalid DWARF CIE for __clone in musl. Reproducer: docker run -it --privileged python:3.10-alpine sh And in the container: apk add --update musl-dbg elfutils python3.10 -c "import os, threading; threading.Thread(target=lambda: os.system(f'eu-stack --pid={os.getpid()}')).start()" That spawns a thread that forks a subprocess that runs `eu-stack` on its parent, and reproduces the issue. If you remove the thread and just run: python3.10 -c "import os; os.system(f'eu-stack --pid={os.getpid()}')" then unwinding succeeds, ending at `_start`.