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

Re: ruby1.9.1 hangs again



Hi.

A change in Ruby caused it to hang again, likely due to a pthread
semantic difference on kfreebsd. It doesn't hang, neither on Linux nor
on FreeBSD.

Affected package is the experimental one. It's a pre-release snapshot
(candidate RC1) for Ruby 1.9.3, to be released in september, and likely
the default Ruby implementation in wheezy.

Please see http://redmine.ruby-lang.org/issues/5240

Many thanks for bisecting it.
I looked at the diff 32243:32244.

The change in general should work even for our slightly broken pthread semantic.
It should be possible to workaround it by encapsulating timer_thread_pipe_owner_proces usage.

The idea is:

standard code would be

***
bool timer_thread_running()
{
   return timer_thread_pipe_owner_process == getpid();
}

void timer_thread_set()
{
   timer_thread_pipe_owner_process = getpid();
}

void timer_thread_child_at_fork()
{
}
***

and somewhere during initialization

pthread_atfork(NULL, NULL, timer_thread_child_at_fork)

And our code will be

***
bool timer_thread_running()
{
   return timer_thread_pipe_owner_process == 1;
}

void timer_thread_set()
{
   timer_thread_pipe_owner_process = 1;
}

void timer_thread_child_at_fork()
{
   timer_thread_pipe_owner_process = 0;
}
***

Even on fully conforming implementation might be our variant better,
as getpid() might be costly system call.

Thanks again for investigating it.

	Petr


Reply to: