Comment 8 for bug 1489379

------- Comment From <email address hidden> 2015-09-03 12:25 EDT-------
> Okay, using a custom libchecktur.so built without -fexceptions..
> It works fine in the installer environment, for its purposes.

> This should be OK as there's no multipathd (which exercises the path checkers more) running in the installer.
> I'll formalize/support this in another comment.

The only places that pthread_cancel() is called in libchecktur.so (tur.c + libsg.c) are 2 functions in tur.c:
1) libcheck_free()
2) libcheck_check()

And their calls to pthread_cancel() are /not/ exercised when /not/ in daemon mode
(i.e., running as multipath, not multipathd; as in the installer).

It's only in daemon mode that the checker goes into async mode -- via get_state() -> checker_set_async().
- And it's only in async mode that libcheck_check() might call pthread_cancel(),
- And it's only in async mode that libcheck_check() might set 'holders' to a value
for which libcheck_free() might call pthread_cancel() (holders > 1).

file libmultipath/discovery.c:

get_state (struct path * pp, int daemon)
{
...
condlog(3, "%s: get_state", pp->dev);

if (!checker_selected(c)) {
...
select_checker(pp);
if (!checker_selected(c)) {
condlog(3, "%s: No checker selected", pp->dev);
return PATH_UNCHECKED;
}
...
if (daemon)
checker_set_async(c);

file libmultipath/checkers.c:

void checker_set_async (struct checker * c)
{
if (!c)
return;
c->sync = 0;
}

file libmultipath/checkers/tur.c:

extern int
libcheck_check (struct checker * c)
{
...
if (c->sync)
return tur_check(c->fd, c->timeout, c->message);

/*
* Async mode
*/
...
if (ct->running) {
...
if (tur_check_async_timeout(c)) {
condlog(3, "%d:%d: tur checker timeout",
TUR_DEVT(ct));
pthread_cancel(ct->thread);
...
/* Start new TUR checker */
...
ct->holders++;

int libcheck_init (struct checker * c)
{
...
ct->holders = 1;
...

void libcheck_free (struct checker * c)
...
ct->holders--;
...
if (holders)
pthread_cancel(thread);
...

------- Comment From <email address hidden> 2015-09-03 12:28 EDT-------
Given the supporting evidence provided, I'll work on a patch to build multipath-udeb without -fexceptions.

(In reply to comment #22)
> Fortunately enough, the *only* ELF (binary/shared-library) in the
> multipath-udeb that requires libgcc_s is... libchecktur.so

(In reply to comment #23)
> Okay, using a custom libchecktur.so built without -fexceptions..
> It works fine in the installer environment, for its purposes.
>
> This should be OK as there's no multipathd (which exercises the path
> checkers more) running in the installer.

(In reply to comment #24)
> The only places that pthread_cancel() is called in libchecktur.so (tur.c +
> libsg.c) are 2 functions in tur.c:
...
> And their calls to pthread_cancel() are /not/ exercised when /not/ in daemon
> mode
> (i.e., running as multipath, not multipathd; as in the installer).