Bug 263825 - umtx: Sporadic hang in glibc test case in Linuxulator's signal trampoline code on arm64 (passes on amd64)
Summary: umtx: Sporadic hang in glibc test case in Linuxulator's signal trampoline cod...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Many People
Assignee: Andrew Turner
URL: https://reviews.freebsd.org/D35150
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2022-05-06 19:24 UTC by Dmitry Chagin
Modified: 2022-06-27 08:41 UTC (History)
3 users (show)

See Also:


Attachments
test (5.73 KB, text/plain)
2022-05-07 11:13 UTC, Dmitry Chagin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Chagin freebsd_committer freebsd_triage 2022-05-06 19:24:22 UTC
While testing arm64 Linuxulator's signal trampoline code I found glibc test which fails on native FreeBSD arm64 (sporadically hangs), but pass on amd64.
Seems to me a some CAS problem.
Unfortunately,  I'm not familiar with arm architecture.

Test, adopted to the FreeBSD here:

https://people.freebsd.org/~dchagin/tst-cond25.c

Btw, I tested it under qemu on mac os m1, maybe problem is here?
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2022-05-06 23:07:35 UTC
@dmitry Can you attach the test case here. Also, is it possible to add a failing test to FreeBSD CI?
Comment 2 Dmitry Chagin freebsd_committer freebsd_triage 2022-05-07 11:13:07 UTC
Created attachment 233787 [details]
test

Attached, however, as I pointed out earlier, this is a native FreeBSD Aarch64 port bug, not an Linuxulator's bug.
Comment 3 John F. Carr 2022-05-09 12:32:32 UTC
I can confirm this running native stable/13 on Ampere eMAG and current on Cortex A-57.  The program sometimes hangs.

Running in a debugger I get occasional addressing errors (segfault or bad address). I think the errors are caused by a bad interaction between lldb and system calls.  Conceivably it is a scheduling problem that only shows up with a debugger.
Comment 4 Andrew Turner freebsd_committer freebsd_triage 2022-05-09 15:03:13 UTC
https://reviews.freebsd.org/D35150 fixes this for me.
Comment 5 Dmitry Chagin freebsd_committer freebsd_triage 2022-05-09 15:48:52 UTC
(In reply to Andrew Turner from comment #4)

seems to me yes, thank you
Comment 6 commit-hook freebsd_committer freebsd_triage 2022-05-19 10:31:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=11a6ecd4258b9108fb19420ec5db297f6d99a842

commit 11a6ecd4258b9108fb19420ec5db297f6d99a842
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2022-05-09 14:28:56 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2022-05-19 10:30:21 +0000

    Handle cas failure when the compare succeeds

    When locking a priority inherit mutex we perform a compare and swap
    operation to try and acquire the mutex. This may fail even when the
    compare succeeds.

    Check and handle this case.

    PR:             263825
    Reviewed by:    kib, markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D35150

 sys/kern/kern_umtx.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Comment 7 commit-hook freebsd_committer freebsd_triage 2022-06-07 14:24:14 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f10d87df48a49136ea9ceefbe8171f24546f27c

commit 3f10d87df48a49136ea9ceefbe8171f24546f27c
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2022-05-09 14:28:56 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2022-06-07 14:20:18 +0000

    Handle cas failure when the compare succeeds

    When locking a priority inherit mutex we perform a compare and swap
    operation to try and acquire the mutex. This may fail even when the
    compare succeeds.

    Check and handle this case.

    PR:             263825
    Reviewed by:    kib, markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D35150

    (cherry picked from commit 11a6ecd4258b9108fb19420ec5db297f6d99a842)

 sys/kern/kern_umtx.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Comment 8 Dmitry Chagin freebsd_committer freebsd_triage 2022-06-27 08:41:01 UTC
thank you!