bug-libsigsegv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sigsegv_register and async-safety


From: Bruno Haible
Subject: Re: sigsegv_register and async-safety
Date: Mon, 01 Jun 2020 19:17:33 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; )

Hi Marc,

> when a sigsegv handler is installed that uses sigsegv_dispatch, how
> can we achieve async-safety in multithreaded programs?
> 
> One thread may want to register a new area handler while a
> segmentation fault is currently handled.

You are right. Multithreaded use of 'sigsegv_register' and 'sigsegv_unregister'
will be causing problems.

> I may be able to think of some complicated ways to solve this problem,
> but maybe there is a simple one.

I don't see a good easy fix either. One would need an interrupt-safe balanced
binary tree.

An easy fix would be that 'sigsegv_register' and 'sigsegv_unregister' clone
the entire binary tree first, then make an insert or delete in it, and finally
replace the root of the binary tree atomically. But then the complexity
of building a binary tree with N elements would be O(N² log N), not O(N log N).

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]