Message ID | 20210104105451.6408-1-wangshuo47@huawei.com |
---|---|
State | Committed |
Commit | cd6274089f7a7603cdaf2a24cef575fa61d3772e |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4895F386F400; Mon, 4 Jan 2021 10:55:11 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by sourceware.org (Postfix) with ESMTPS id DAA6E385041D for <libc-alpha@sourceware.org>; Mon, 4 Jan 2021 10:55:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DAA6E385041D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=wangshuo47@huawei.com Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4D8XYm2jssz15nXc; Mon, 4 Jan 2021 18:54:04 +0800 (CST) Received: from huawei.com (10.174.176.87) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Mon, 4 Jan 2021 18:54:51 +0800 From: Shuo Wang <wangshuo47@huawei.com> To: <libc-alpha@sourceware.org>, <carlos@redhat.com> Subject: [PATCH] fix stack missing after sp is updated Date: Mon, 4 Jan 2021 18:54:51 +0800 Message-ID: <20210104105451.6408-1-wangshuo47@huawei.com> X-Mailer: git-send-email 2.19.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.174.176.87] X-CFilter-Loop: Reflected X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Cc: hushiyuan@huawei.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
fix stack missing after sp is updated
|
|
Commit Message
Shuo Wang
Jan. 4, 2021, 10:54 a.m. UTC
After sp is updated, the CFA offset should be set before next instruction. Tested in glibc-2.28 Before fixing: Thread 2 "xxxxxxx" hit Breakpoint 1, _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 149 stp x1, x2, [sp, #-32]! Missing separate debuginfos, use: dnf debuginfo-install libgcc-7.3.0-20190804.h24.aarch64 (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) at /home/test/test_function.c:30 #2 0x0000000000400c08 in initaaa () at thread.c:58 #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 #5 0x0000ffffbf5669ec in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 (gdb) ni _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:150 150 stp x3, x4, [sp, #16] (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:150 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) at /home/test/test_function.c:30 #2 0x0000000000000000 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) ni _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157 157 mrs x4, tpidr_el0 (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) at /home/test/test_function.c:30 #2 0x0000000000400c08 in initaaa () at thread.c:58 #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 #5 0x0000ffffbf5669ec in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 After fixing: Thread 2 "xxxxxxx" hit Breakpoint 1, _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 149 stp x1, x2, [sp, #-32]! Missing separate debuginfos, use: dnf debuginfo-install libgcc-7.3.0-20190804.h24.aarch64 (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) at /home/test/test_function.c:30 #2 0x0000000000400c08 in initaaa () at thread.c:58 #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 #5 0x0000ffffbf567aac in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 (gdb) ni 151 stp x3, x4, [sp, #16] (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:151 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) at /home/test/test_function.c:30 #2 0x0000000000400c08 in initaaa () at thread.c:58 #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 #5 0x0000ffffbf567aac in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 (gdb) ni 157 mrs x4, tpidr_el0 (gdb) bt #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157 #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) at /home/test/test_function.c:30 #2 0x0000000000400c08 in initaaa () at thread.c:58 #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 #5 0x0000ffffbf567aac in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 Signed-off-by: liqingqing <liqingqing3@huawei.com> Signed-off-by: Shuo Wang <wangshuo47@huawei.com> --- sysdeps/aarch64/dl-tlsdesc.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
The 01/04/2021 18:54, Shuo Wang wrote: > After sp is updated, the CFA offset should be set before next instruction. > Tested in glibc-2.28 > Before fixing: > Thread 2 "xxxxxxx" hit Breakpoint 1, _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 > 149 stp x1, x2, [sp, #-32]! > Missing separate debuginfos, use: dnf debuginfo-install libgcc-7.3.0-20190804.h24.aarch64 > (gdb) bt > #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 > #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) > at /home/test/test_function.c:30 > #2 0x0000000000400c08 in initaaa () at thread.c:58 > #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 > #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 > #5 0x0000ffffbf5669ec in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 > (gdb) ni > _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:150 > 150 stp x3, x4, [sp, #16] > (gdb) bt > #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:150 > #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) > at /home/test/test_function.c:30 > #2 0x0000000000000000 in ?? () > Backtrace stopped: previous frame identical to this frame (corrupt stack?) > (gdb) ni > _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157 > 157 mrs x4, tpidr_el0 > (gdb) bt > #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157 > #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) > at /home/test/test_function.c:30 > #2 0x0000000000400c08 in initaaa () at thread.c:58 > #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 > #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 > #5 0x0000ffffbf5669ec in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 > > After fixing: > Thread 2 "xxxxxxx" hit Breakpoint 1, _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 > 149 stp x1, x2, [sp, #-32]! > Missing separate debuginfos, use: dnf debuginfo-install libgcc-7.3.0-20190804.h24.aarch64 > (gdb) bt > #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:149 > #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) > at /home/test/test_function.c:30 > #2 0x0000000000400c08 in initaaa () at thread.c:58 > #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 > #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 > #5 0x0000ffffbf567aac in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 > (gdb) ni > 151 stp x3, x4, [sp, #16] > (gdb) bt > #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:151 > #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) > at /home/test/test_function.c:30 > #2 0x0000000000400c08 in initaaa () at thread.c:58 > #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 > #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 > #5 0x0000ffffbf567aac in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 > (gdb) ni > 157 mrs x4, tpidr_el0 > (gdb) bt > #0 _dl_tlsdesc_dynamic () at ../sysdeps/aarch64/dl-tlsdesc.S:157 > #1 0x0000ffffbe4fbb44 in OurFunction (threadId=3194870184) > at /home/test/test_function.c:30 > #2 0x0000000000400c08 in initaaa () at thread.c:58 > #3 0x0000000000400c50 in thread_proc (param=0x0) at thread.c:71 > #4 0x0000ffffbf6918bc in start_thread (arg=0xfffffffff29f) at pthread_create.c:486 > #5 0x0000ffffbf567aac in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78 > > Signed-off-by: liqingqing <liqingqing3@huawei.com> > Signed-off-by: Shuo Wang <wangshuo47@huawei.com> please add 'aarch64: ' prefix to the subject. i think it's enough to have the before the fix gdb session in the commit message. with those changes this is ok to commit. (if you don't have commit rights then send an updated patch and i'll commit it for you) > --- > sysdeps/aarch64/dl-tlsdesc.S | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sysdeps/aarch64/dl-tlsdesc.S b/sysdeps/aarch64/dl-tlsdesc.S > index 0046d29f9b..425e45a50f 100644 > --- a/sysdeps/aarch64/dl-tlsdesc.S > +++ b/sysdeps/aarch64/dl-tlsdesc.S > @@ -150,8 +150,8 @@ _dl_tlsdesc_dynamic: > /* Save just enough registers to support fast path, if we fall > into slow path we will save additional registers. */ > stp x1, x2, [sp, #-32]! > - stp x3, x4, [sp, #16] > cfi_adjust_cfa_offset (32) > + stp x3, x4, [sp, #16] > cfi_rel_offset (x1, 0) > cfi_rel_offset (x2, 8) > cfi_rel_offset (x3, 16) > -- > 2.23.0 >
diff --git a/sysdeps/aarch64/dl-tlsdesc.S b/sysdeps/aarch64/dl-tlsdesc.S index 0046d29f9b..425e45a50f 100644 --- a/sysdeps/aarch64/dl-tlsdesc.S +++ b/sysdeps/aarch64/dl-tlsdesc.S @@ -150,8 +150,8 @@ _dl_tlsdesc_dynamic: /* Save just enough registers to support fast path, if we fall into slow path we will save additional registers. */ stp x1, x2, [sp, #-32]! - stp x3, x4, [sp, #16] cfi_adjust_cfa_offset (32) + stp x3, x4, [sp, #16] cfi_rel_offset (x1, 0) cfi_rel_offset (x2, 8) cfi_rel_offset (x3, 16)