Reproducer and verification of the fix in tenacious (amd64, LXC container
upgraded from stonking, 4 CPUs).
Test case (verify-lp2175640.sh, attached): a minimal .NET 10 console app in
which 64 threads throw and catch 500 exceptions each, all starting at the same
moment. The concurrent first exceptions make libunwind validate addresses on
many threads at once, which hits the pipe initialization race. The script runs
the app N times in fresh processes against the installed libunwind8 and counts
aborts (exit code 134, "Fatal error. Internal CLR error. (0x80131506)").
It also confirms that libcoreclr.so links the system libunwind.
Results:
libunwind8 1.8.3-0ubuntu1 (archive): 2/100 runs aborted -> FAIL
libunwind8 1.8.3-0ubuntu2~ppa2 (PPA): 0/100 runs aborted -> PASS
Steps:
lxc launch ubuntu-daily:stonking dn10
lxc config set dn10 limits.cpu 4
lxc exec dn10 -- bash -c "sed -i 's/stonking/tenacious/g'
/etc/apt/sources.list.d/ubuntu.sources && apt-get update && apt-get
full-upgrade -y"
lxc restart dn10
lxc file push verify-lp2175640.sh dn10/root/
# 1. Reproduce with the archive libunwind8 (expected: FAIL)
lxc exec dn10 -- bash /root/verify-lp2175640.sh 100
# 2. Install the fixed libunwind8
lxc exec dn10 -- add-apt-repository -y ppa:rinconjr/libunwind-lp2175640
lxc exec dn10 -- apt-get install -y --only-upgrade libunwind8
# 3. Run the same script again (expected: PASS, 0 aborts)
lxc exec dn10 -- bash /root/verify-lp2175640.sh 100
Program.cs used to test this race condition (embedded in the script
attached):
// N threads throw their first exceptions at the same moment, which is
// where libunwind's lazily created address-validation pipe races.
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
var threads = int.Parse(args[0]);
var throwsEach = int.Parse(args[1]);
var go = new ManualResetEventSlim(false);
var all = new Thread[threads];
for (var i = 0; i < threads; i++)
{
all[i] = new Thread(() =>
{
go.Wait();
for (var j = 0; j < throwsEach; j++)
{
try { Thrower(j); } catch (IOException) { }
}
});
all[i].Start();
}
Thread.Sleep(50);
go.Set();
foreach (var t in all) t.Join();
Console.WriteLine("ok");
[MethodImpl(MethodImplOptions.NoInlining)]
static void Thrower(int j) => throw new IOException("planted " + j);
Output of both runs attached.
** Attachment added: "verify-lp2175640.sh"
https://bugs.launchpad.net/ubuntu/+source/libunwind/+bug/2175640/+attachment/6020969/+files/verify-lp2175640.sh
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2175640
Title:
libunwind 1.8.x: race in unw_address_is_valid() pipe initialization
makes unw_step() fail under concurrent unwinding (crashes .NET with
0x80131506)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libunwind/+bug/2175640/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs