This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Only construct ucontext for SA_SIGINFO signal handlers


On 03/04/2015 15:08, Corinna Vinschen wrote:
On Apr  3 13:51, Jon TURNEY wrote:
On 03/04/2015 13:17, Corinna Vinschen wrote:
On Apr  3 13:18, Corinna Vinschen wrote:
On Apr  2 20:30, Jon TURNEY wrote:

        sigset_t this_oldmask = set_process_mask_delta ();
-      thiscontext.uc_sigmask = this_oldmask;
+      context.uc_sigmask = this_oldmask;
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This call to set_process_mask_delta() should occur before constructing
the context, so that filling in uc_sigmask can be moved into the above
`'if' branch.

Ok, I will move it.

On second thought, isn't this slightly wrong anyway?  Shouldn't that be

          context.uc_sigmask = _my_tls.sigmask;
	 context.uc_mcontext.oldmask = this_oldmask;

As I wrote elsewhere:  You'll have to help me understand what the difference
in meaning between ucontext_t.uc_sigmask and ucontext_t.uc_mcontext.oldmask
is.

I don't see how the value of _my_tls.sigmask has any meaning at that point
in the code.

Ok, I had a look into the Linux source and searched the web, and here's
the problem.

One is that sigset_t on Linux is not just a 32 or 64 bit bitmask anymore,
but an array of ulong's used as a rather big sigmask.

OTOH, mcontext_t::oldmask is only the size of "unsigned long".  In fact,
as it turns out by inspecting the Linux kernel, oldmask is nothing else
than the first bits of uc_sigmask which fit into an unsigned long.  And
in the net I found that oldmask is just the old representation of
sigset_t, before the Linux kernel allowed more signals than fit into
a bitmask of unsigned long size.  In fact, it's only for backward compat,
but unused these days.

Given that, setting context.uc_sigmask to this_oldmask is apparently
the right thing to do.  For emulating backward compat (which we don't
need, but it also doesn't hurt), we could set oldmask to the same
value:

   context.uc_sigmask = context.uc_mcontext.oldmask = this_oldmask;


Thank you very much for researching this. I tried but wasn't able to discover anything much.

What you suggest seems right, so I'll make an updated patch including that.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]