Bug 202196 - Don't try to use backtrace() on MIPS
Summary: Don't try to use backtrace() on MIPS
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Guillaume Emont
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-09-25 03:55 PDT by Guillaume Emont
Modified: 2019-09-30 04:54 PDT (History)
9 users (show)

See Also:


Attachments
Patch (1.58 KB, patch)
2019-09-25 04:01 PDT, Guillaume Emont
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Emont 2019-09-25 03:55:14 PDT
backtrace() on mips seems to always return 1 on mips/glibc (I tried with buildroot, debian stable and debian testing), which renders it useless and breaks a RELEASE_ASSERT in StackTrace::captureStackTrace().
Comment 1 Guillaume Emont 2019-09-25 04:01:29 PDT
Created attachment 379535 [details]
Patch

Patch implementing this.
Comment 2 Adrian Perez 2019-09-30 04:13:51 PDT
I have not checked glibc's code, but I expect that for code built
without frame pointers (the default for MIPS) it's always returning
an error because it's hard to walk the stack otherwise.

For binaries with .eh_frame sections, libunwind should work, but that
would still require building passing “-fasynchronous-unwind-tables”
to GCC. That might be an option if we want to bring back support for
backtraces on MIPS at some point.

Therefore, the patch is r=me, because plain backtrace() will be useless
99% of the time for MIPS.
Comment 3 WebKit Commit Bot 2019-09-30 04:18:21 PDT
Comment on attachment 379535 [details]
Patch

Clearing flags on attachment: 379535

Committed r250516: <https://trac.webkit.org/changeset/250516>
Comment 4 WebKit Commit Bot 2019-09-30 04:18:22 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Radar WebKit Bug Importer 2019-09-30 04:19:21 PDT
<rdar://problem/55835215>
Comment 6 Guillaume Emont 2019-09-30 04:54:08 PDT
(In reply to Adrian Perez from comment #2)
> I have not checked glibc's code, but I expect that for code built
> without frame pointers (the default for MIPS) it's always returning
> an error because it's hard to walk the stack otherwise.
> 
> For binaries with .eh_frame sections, libunwind should work, but that
> would still require building passing “-fasynchronous-unwind-tables”
> to GCC. That might be an option if we want to bring back support for
> backtraces on MIPS at some point.
> 
> Therefore, the patch is r=me, because plain backtrace() will be useless
> 99% of the time for MIPS.

Thanks for explaining the reasons behind backtrace() being useless on MIPS. Note that technically, it's not returning an error (AFAIK the backtrace()'s API does not allow for that), but it's just giving a stack trace of size one (the current function), which confuses WTF code (even though it has code to ignore backtrace() if it returns 0, a return of 1 is not an expected failure case).