* [PATCH] Fix WAIT_FOR_DEBUGGER for container tests.
@ 2023-09-28 10:50 Stefan Liebler
2023-10-03 18:12 ` Adhemerval Zanella Netto
2023-10-12 8:04 ` Stefan Liebler
0 siblings, 2 replies; 6+ messages in thread
From: Stefan Liebler @ 2023-09-28 10:50 UTC (permalink / raw)
To: libc-alpha; +Cc: dj, Stefan Liebler
For container tests, gdb needs to set the sysroot to the corresponding
testroot.root directory. The assumption was that PIDs < 3 means that
we are running within a container.
Starting with commit 2fe64148a81f0d78050c302f34a6853d21f7cae4
"Allow for unpriviledged nested containers", the default is to use
the PID namespace of the parent. Thus support_test_main.c does not
recognize our container anymore.
This patch now assumes that we are running inside a container if
test-container.c has set PID_OUTSIDE_CONTAINER and always uses this
PID independent of having a new PID namespace or not.
---
support/support_test_main.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/support/support_test_main.c b/support/support_test_main.c
index c20c19e774..f19fce5644 100644
--- a/support/support_test_main.c
+++ b/support/support_test_main.c
@@ -195,16 +195,14 @@ run_test_function (int argc, char **argv, const struct test_config *config)
char *gdb_script_name;
int inside_container = 0;
- mypid = getpid();
- if (mypid < 3)
+ const char *outside_pid = getenv("PID_OUTSIDE_CONTAINER");
+ if (outside_pid)
{
- const char *outside_pid = getenv("PID_OUTSIDE_CONTAINER");
- if (outside_pid)
- {
- mypid = atoi (outside_pid);
- inside_container = 1;
- }
+ mypid = atoi (outside_pid);
+ inside_container = 1;
}
+ else
+ mypid = getpid();
gdb_script_name = (char *) xmalloc (strlen (argv[0]) + strlen (".gdb") + 1);
sprintf (gdb_script_name, "%s.gdb", argv[0]);
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix WAIT_FOR_DEBUGGER for container tests.
2023-09-28 10:50 [PATCH] Fix WAIT_FOR_DEBUGGER for container tests Stefan Liebler
@ 2023-10-03 18:12 ` Adhemerval Zanella Netto
2023-10-04 8:03 ` Stefan Liebler
2023-10-12 8:04 ` Stefan Liebler
1 sibling, 1 reply; 6+ messages in thread
From: Adhemerval Zanella Netto @ 2023-10-03 18:12 UTC (permalink / raw)
To: Stefan Liebler, libc-alpha; +Cc: dj
On 28/09/23 07:50, Stefan Liebler wrote:
> For container tests, gdb needs to set the sysroot to the corresponding
> testroot.root directory. The assumption was that PIDs < 3 means that
> we are running within a container.
>
> Starting with commit 2fe64148a81f0d78050c302f34a6853d21f7cae4
> "Allow for unpriviledged nested containers", the default is to use
> the PID namespace of the parent. Thus support_test_main.c does not
> recognize our container anymore.
>
> This patch now assumes that we are running inside a container if
> test-container.c has set PID_OUTSIDE_CONTAINER and always uses this
> PID independent of having a new PID namespace or not.
Do you have a scenario where debugglibc is failing to attach to a container
test? I am trying to see if something it broken, but it does seems to be
working.
> ---
> support/support_test_main.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/support/support_test_main.c b/support/support_test_main.c
> index c20c19e774..f19fce5644 100644
> --- a/support/support_test_main.c
> +++ b/support/support_test_main.c
> @@ -195,16 +195,14 @@ run_test_function (int argc, char **argv, const struct test_config *config)
> char *gdb_script_name;
> int inside_container = 0;
>
> - mypid = getpid();
> - if (mypid < 3)
> + const char *outside_pid = getenv("PID_OUTSIDE_CONTAINER");
> + if (outside_pid)
> {
> - const char *outside_pid = getenv("PID_OUTSIDE_CONTAINER");
> - if (outside_pid)
> - {
> - mypid = atoi (outside_pid);
> - inside_container = 1;
> - }
> + mypid = atoi (outside_pid);
> + inside_container = 1;
> }
> + else
> + mypid = getpid();
>
> gdb_script_name = (char *) xmalloc (strlen (argv[0]) + strlen (".gdb") + 1);
> sprintf (gdb_script_name, "%s.gdb", argv[0]);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix WAIT_FOR_DEBUGGER for container tests.
2023-10-03 18:12 ` Adhemerval Zanella Netto
@ 2023-10-04 8:03 ` Stefan Liebler
2023-10-13 13:20 ` Adhemerval Zanella Netto
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Liebler @ 2023-10-04 8:03 UTC (permalink / raw)
To: Adhemerval Zanella Netto, libc-alpha; +Cc: dj
On 03.10.23 20:12, Adhemerval Zanella Netto wrote:
>
>
> On 28/09/23 07:50, Stefan Liebler wrote:
>> For container tests, gdb needs to set the sysroot to the corresponding
>> testroot.root directory. The assumption was that PIDs < 3 means that
>> we are running within a container.
>>
>> Starting with commit 2fe64148a81f0d78050c302f34a6853d21f7cae4
>> "Allow for unpriviledged nested containers", the default is to use
>> the PID namespace of the parent. Thus support_test_main.c does not
>> recognize our container anymore.
>>
>> This patch now assumes that we are running inside a container if
>> test-container.c has set PID_OUTSIDE_CONTAINER and always uses this
>> PID independent of having a new PID namespace or not.
>
> Do you have a scenario where debugglibc is failing to attach to a container
> test? I am trying to see if something it broken, but it does seems to be
> working.
>
For me, it failed with "WAIT_FOR_DEBUGGER=1 make test
t=nss/tst-nss-gai-hv2-canonname". After gdb attached to the process, gdb
has not found a suitable binary and thus can't set wait_for_debugger.
The same seems also to happen for "./debugglibc.sh -c --
./nss/tst-nss-gai-hv2-canonname".
Can you please check if your ./nss/tst-nss-gai-hv2-canonname.gdb
contains "set sysroot"?
For me it does not work on s390x / x86_64. In both cases, I'm using
Fedora 38.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix WAIT_FOR_DEBUGGER for container tests.
2023-09-28 10:50 [PATCH] Fix WAIT_FOR_DEBUGGER for container tests Stefan Liebler
2023-10-03 18:12 ` Adhemerval Zanella Netto
@ 2023-10-12 8:04 ` Stefan Liebler
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Liebler @ 2023-10-12 8:04 UTC (permalink / raw)
To: libc-alpha; +Cc: dj
On 28.09.23 12:50, Stefan Liebler wrote:
> For container tests, gdb needs to set the sysroot to the corresponding
> testroot.root directory. The assumption was that PIDs < 3 means that
> we are running within a container.
>
> Starting with commit 2fe64148a81f0d78050c302f34a6853d21f7cae4
> "Allow for unpriviledged nested containers", the default is to use
> the PID namespace of the parent. Thus support_test_main.c does not
> recognize our container anymore.
>
> This patch now assumes that we are running inside a container if
> test-container.c has set PID_OUTSIDE_CONTAINER and always uses this
> PID independent of having a new PID namespace or not.
> ---
> support/support_test_main.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/support/support_test_main.c b/support/support_test_main.c
> index c20c19e774..f19fce5644 100644
> --- a/support/support_test_main.c
> +++ b/support/support_test_main.c
> @@ -195,16 +195,14 @@ run_test_function (int argc, char **argv, const struct test_config *config)
> char *gdb_script_name;
> int inside_container = 0;
>
> - mypid = getpid();
> - if (mypid < 3)
> + const char *outside_pid = getenv("PID_OUTSIDE_CONTAINER");
> + if (outside_pid)
> {
> - const char *outside_pid = getenv("PID_OUTSIDE_CONTAINER");
> - if (outside_pid)
> - {
> - mypid = atoi (outside_pid);
> - inside_container = 1;
> - }
> + mypid = atoi (outside_pid);
> + inside_container = 1;
> }
> + else
> + mypid = getpid();
>
> gdb_script_name = (char *) xmalloc (strlen (argv[0]) + strlen (".gdb") + 1);
> sprintf (gdb_script_name, "%s.gdb", argv[0]);
ping
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix WAIT_FOR_DEBUGGER for container tests.
2023-10-04 8:03 ` Stefan Liebler
@ 2023-10-13 13:20 ` Adhemerval Zanella Netto
2023-10-16 7:53 ` Stefan Liebler
0 siblings, 1 reply; 6+ messages in thread
From: Adhemerval Zanella Netto @ 2023-10-13 13:20 UTC (permalink / raw)
To: Stefan Liebler, libc-alpha; +Cc: dj
On 04/10/23 05:03, Stefan Liebler wrote:
> On 03.10.23 20:12, Adhemerval Zanella Netto wrote:
>>
>>
>> On 28/09/23 07:50, Stefan Liebler wrote:
>>> For container tests, gdb needs to set the sysroot to the corresponding
>>> testroot.root directory. The assumption was that PIDs < 3 means that
>>> we are running within a container.
>>>
>>> Starting with commit 2fe64148a81f0d78050c302f34a6853d21f7cae4
>>> "Allow for unpriviledged nested containers", the default is to use
>>> the PID namespace of the parent. Thus support_test_main.c does not
>>> recognize our container anymore.
>>>
>>> This patch now assumes that we are running inside a container if
>>> test-container.c has set PID_OUTSIDE_CONTAINER and always uses this
>>> PID independent of having a new PID namespace or not.
>>
>> Do you have a scenario where debugglibc is failing to attach to a container
>> test? I am trying to see if something it broken, but it does seems to be
>> working.
>>
> For me, it failed with "WAIT_FOR_DEBUGGER=1 make test
> t=nss/tst-nss-gai-hv2-canonname". After gdb attached to the process, gdb
> has not found a suitable binary and thus can't set wait_for_debugger.
Ok, I see the failure now.
>
> The same seems also to happen for "./debugglibc.sh -c --
> ./nss/tst-nss-gai-hv2-canonname".
>
> Can you please check if your ./nss/tst-nss-gai-hv2-canonname.gdb
> contains "set sysroot"?
> For me it does not work on s390x / x86_64. In both cases, I'm using
> Fedora 38.
Yes, with the patch the sysroot is now set correctly.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix WAIT_FOR_DEBUGGER for container tests.
2023-10-13 13:20 ` Adhemerval Zanella Netto
@ 2023-10-16 7:53 ` Stefan Liebler
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Liebler @ 2023-10-16 7:53 UTC (permalink / raw)
To: Adhemerval Zanella Netto, libc-alpha; +Cc: dj
On 13.10.23 15:20, Adhemerval Zanella Netto wrote:
>
>
> On 04/10/23 05:03, Stefan Liebler wrote:
>> On 03.10.23 20:12, Adhemerval Zanella Netto wrote:
>>>
>>>
>>> On 28/09/23 07:50, Stefan Liebler wrote:
>>>> For container tests, gdb needs to set the sysroot to the corresponding
>>>> testroot.root directory. The assumption was that PIDs < 3 means that
>>>> we are running within a container.
>>>>
>>>> Starting with commit 2fe64148a81f0d78050c302f34a6853d21f7cae4
>>>> "Allow for unpriviledged nested containers", the default is to use
>>>> the PID namespace of the parent. Thus support_test_main.c does not
>>>> recognize our container anymore.
>>>>
>>>> This patch now assumes that we are running inside a container if
>>>> test-container.c has set PID_OUTSIDE_CONTAINER and always uses this
>>>> PID independent of having a new PID namespace or not.
>>>
>>> Do you have a scenario where debugglibc is failing to attach to a container
>>> test? I am trying to see if something it broken, but it does seems to be
>>> working.
>>>
>> For me, it failed with "WAIT_FOR_DEBUGGER=1 make test
>> t=nss/tst-nss-gai-hv2-canonname". After gdb attached to the process, gdb
>> has not found a suitable binary and thus can't set wait_for_debugger.
>
> Ok, I see the failure now.
>
>>
>> The same seems also to happen for "./debugglibc.sh -c --
>> ./nss/tst-nss-gai-hv2-canonname".
>>
>> Can you please check if your ./nss/tst-nss-gai-hv2-canonname.gdb
>> contains "set sysroot"?
>> For me it does not work on s390x / x86_64. In both cases, I'm using
>> Fedora 38.
> Yes, with the patch the sysroot is now set correctly.
>
> LGTM, thanks.
>
> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Thanks for the review. I've just committed the patch.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-10-16 7:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-28 10:50 [PATCH] Fix WAIT_FOR_DEBUGGER for container tests Stefan Liebler
2023-10-03 18:12 ` Adhemerval Zanella Netto
2023-10-04 8:03 ` Stefan Liebler
2023-10-13 13:20 ` Adhemerval Zanella Netto
2023-10-16 7:53 ` Stefan Liebler
2023-10-12 8:04 ` Stefan Liebler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).