This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] RISC-V: Fix elfutils testsuite unwind failures.
- From: DJ Delorie <dj at redhat dot com>
- To: Jim Wilson <jimw at sifive dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 04 Feb 2019 17:37:16 -0500
- Subject: Re: [PATCH] RISC-V: Fix elfutils testsuite unwind failures.
I'm OK with this patch plus or minus the return from main comment I
added below. If someone "in the know" can comment on that comment, I
can commit the patch once we have consensus on it.
Jim Wilson <jimw@sifive.com> writes:
> -CFLAGS-tst-unwind-main.c += -funwind-tables
> +CFLAGS-tst-unwind-main.c += -funwind-tables -DUSE_PTHREADS=0
This allows for the test to run the "old" way, ok.
> static _Unwind_Reason_Code
> callback (struct _Unwind_Context *ctx, void *arg)
> {
> return _URC_NO_REASON;
> }
>
> -int
> -main (void)
> +static void *
> +func (void *a)
> {
> /* Arrange for this test to be killed if _Unwind_Backtrace runs into an
> endless loop. We cannot use the test driver because the complete
> call chain needs to be compiled with -funwind-tables so that
> - _Unwind_Backtrace is able to reach _start. */
> + _Unwind_Backtrace is able to reach the start routine. */
> alarm (DEFAULT_TIMEOUT);
> _Unwind_Backtrace (callback, 0);
> + return a;
> +}
> +
> +int
> +main (void)
> +{
> +#if USE_PTHREADS
> + pthread_t thr;
> + int rc = pthread_create (&thr, NULL, &func, NULL);
> + if (rc)
> + error (1, rc, "pthread_create");
> + rc = pthread_join (thr, NULL);
> + if (rc)
> + error (1, rc, "pthread_join");
> +#else
> + func (NULL);
> +#endif
> }
main() should return something in the fall-through case, be it zero
(main should exit) or 1 (code shouldn't be reached), now that main()
doesn't end with _Unwind_Backtrace() itself, if for no reason than to
avoid future warnings.
> - tst-rwlock-pwn
> + tst-rwlock-pwn tst-unwind-thread
ok
> +CFLAGS-tst-unwind-thread.c += -funwind-tables
ok, same as original test.
> +#define USE_PTHREADS 1
> +#include "../elf/tst-unwind-main.c"
Ok.
> ENTRY (__thread_start)
> L (thread_start):
> + /* Terminate call stack by noting ra is undefined. Use a dummy
> + .cfi_label to force starting the FDE. */
> + .cfi_label .Ldummy
> + cfi_undefined (ra)
> +
As noted, this matches start.S, so ok.