!3 cope with variable SIGSTKSZ

From: @Miaohe-Lin
Reviewed-by: @louhongxiang
Signed-off-by: @liuzhiqiang26
This commit is contained in:
openeuler-ci-bot 2021-08-10 09:01:43 +00:00 committed by Gitee
commit 096283b6f8
2 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,77 @@
From 8aac320ae8445c5434ab3be1761414a5247e5d42 Mon Sep 17 00:00:00 2001
From: Stefan Hajnoczi <stefanha@redhat.com>
Date: Tue, 13 Apr 2021 16:03:19 +0100
Subject: examples/ucontext-cp.c: cope with variable SIGSTKSZ
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The size of C arrays at file scope must be constant. The following
compiler error occurs with recent upstream glibc (2.33.9000):
CC ucontext-cp
ucontext-cp.c:31:23: error: variably modified stack_buf at file scope
31 | unsigned char stack_buf[SIGSTKSZ];
| ^~~~~~~~~
make[1]: *** [Makefile:26: ucontext-cp] Error 1
The following glibc commit changed SIGSTKSZ from a constant value to a
variable:
commit 6c57d320484988e87e446e2e60ce42816bf51d53
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Feb 1 11:00:38 2021 -0800
sysconf: Add _SC_MINSIGSTKSZ/_SC_SIGSTKSZ [BZ #20305]
...
+# define SIGSTKSZ sysconf (_SC_SIGSTKSZ)
Allocate the stack buffer explicitly to avoid declaring an array at file
scope.
Cc: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
examples/ucontext-cp.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/examples/ucontext-cp.c b/examples/ucontext-cp.c
index 0b2a6b5..ea0c934 100644
--- a/examples/ucontext-cp.c
+++ b/examples/ucontext-cp.c
@@ -28,7 +28,7 @@
typedef struct {
struct io_uring *ring;
- unsigned char stack_buf[SIGSTKSZ];
+ unsigned char *stack_buf;
ucontext_t ctx_main, ctx_fnew;
} async_context;
@@ -115,8 +115,13 @@ static int setup_context(async_context *pctx, struct io_uring *ring)
perror("getcontext");
return -1;
}
- pctx->ctx_fnew.uc_stack.ss_sp = &pctx->stack_buf;
- pctx->ctx_fnew.uc_stack.ss_size = sizeof(pctx->stack_buf);
+ pctx->stack_buf = malloc(SIGSTKSZ);
+ if (!pctx->stack_buf) {
+ perror("malloc");
+ return -1;
+ }
+ pctx->ctx_fnew.uc_stack.ss_sp = pctx->stack_buf;
+ pctx->ctx_fnew.uc_stack.ss_size = SIGSTKSZ;
pctx->ctx_fnew.uc_link = &pctx->ctx_main;
return 0;
@@ -174,6 +179,7 @@ static void copy_file_wrapper(arguments_bundle *pbundle)
free(iov.iov_base);
close(pbundle->infd);
close(pbundle->outfd);
+ free(pbundle->pctx->stack_buf);
free(pbundle->pctx);
free(pbundle);
--
cgit v1.2.3

View File

@ -1,12 +1,14 @@
Name: liburing
Version: 0.7
Release: 1
Release: 2
Summary: Linux-native io_uring I/O access library
License: (GPLv2 with exceptions and LGPLv2+) or MIT
Source0: https://brick.kernel.dk/snaps/%{name}-%{version}.tar.gz
URL: https://git.kernel.dk/cgit/liburing/
BuildRequires: gcc
Patch1: 0001-examples-ucontext-cp.c-cope-with-variable-SIGSTKSZ.patch
%description
Provides native async IO for the Linux kernel, in a fast and efficient
manner, for both buffered and O_DIRECT.
@ -45,5 +47,8 @@ for the Linux-native io_uring.
%{_mandir}/man2/*
%changelog
* Tue Aug 10 2021 Miaohe Lin <linmiaohe@huawei.com> - 0.7-2
- cope with variable SIGSTKSZ
* Mon Feb 22 2021 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 0.7-1
- init liburing v0.7