public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* X widget question
@ 2016-03-20  9:57 Marco Atzeri
  2016-03-22 10:19 ` Jon Turney
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Atzeri @ 2016-03-20  9:57 UTC (permalink / raw)
  To: cygwin

I have finally identified where ncview was
segfaulting on X86_64

The solution was to reverse the order of destruction
for a chain of widgets

         i=0;
-       while( (w = *(diminfo_row_widget + i++)) != NULL )
-               XtDestroyWidget( w );
+       while( (w = *(diminfo_row_widget + i)) != NULL )
+               i++;
+       while( i>0 ) {
+               i--;
+               XtDestroyWidget( *(diminfo_row_widget + i ));
+       }
  }

that were connected by a vertical constraints:

     *(diminfo_row_widget+ll) = XtVaCreateManagedWidget(
            widget_name,
            boxWidgetClass,
            commandcanvas_widget,
            XtNorientation, XtorientHorizontal,
            XtNfromVert, *(diminfo_row_widget + (ll-1)),
            XtNheight, bb_height,
            XtNwidth,  bb_width,
            NULL);

The segfault was inside Xlib when managing the constraints.

As the segfault did not happened on i686, is it possible
that is a race inside Xlib  ?
I have not found in the X Documentation nothing about
requested order of widget destruction in this case.

Thanks in advance
Marco

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: X widget question
  2016-03-20  9:57 X widget question Marco Atzeri
@ 2016-03-22 10:19 ` Jon Turney
  2016-03-22 11:30   ` Marco Atzeri
  0 siblings, 1 reply; 3+ messages in thread
From: Jon Turney @ 2016-03-22 10:19 UTC (permalink / raw)
  To: Marco Atzeri, cygwin

On 20/03/2016 09:57, Marco Atzeri wrote:
> I have finally identified where ncview was
> segfaulting on X86_64
>
> The solution was to reverse the order of destruction
> for a chain of widgets

Nice to see that you have resolved this.

It's not clear from what you write if you are sure there is an 
undocumented ordering constraint (which just happens to not crash on 
32-bit), or if reversing the ordering just happens to make things not 
crash on 64-bit

> The segfault was inside Xlib when managing the constraints.
>
> As the segfault did not happened on i686, is it possible
> that is a race inside Xlib  ?
> I have not found in the X Documentation nothing about
> requested order of widget destruction in this case.

Possible, yes.  It seems more likely that there is a documentation 
error, or a bug in handling widgets which share a constraint being 
destroyed out of order.

I'm afraid finding someone who cares greatly about libXt will be hard, 
but do you think it would now be possible to craft a test case which 
demonstrates the problem?


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: X widget question
  2016-03-22 10:19 ` Jon Turney
@ 2016-03-22 11:30   ` Marco Atzeri
  0 siblings, 0 replies; 3+ messages in thread
From: Marco Atzeri @ 2016-03-22 11:30 UTC (permalink / raw)
  To: cygwin

On 22/03/2016 11:18, Jon Turney wrote:
> On 20/03/2016 09:57, Marco Atzeri wrote:
>> I have finally identified where ncview was
>> segfaulting on X86_64
>>
>> The solution was to reverse the order of destruction
>> for a chain of widgets
>
> Nice to see that you have resolved this.
>
> It's not clear from what you write if you are sure there is an
> undocumented ordering constraint (which just happens to not crash on
> 32-bit), or if reversing the ordering just happens to make things not
> crash on 64-bit

I suspect the second:
Reversing the order just don't trigger the crash as no reformatting of
the constraint chain is needed.
As ncview view works on other 64 bit platform, it seems a
cygwin specific issue.

Debugging the issue I always noted mismatch of 16 bytes in related
  pointers. But as I know little of libXt internals I could 
misunderstand it.

>> The segfault was inside Xlib when managing the constraints.
>>
>> As the segfault did not happened on i686, is it possible
>> that is a race inside Xlib  ?
>> I have not found in the X Documentation nothing about
>> requested order of widget destruction in this case.
>
> Possible, yes.  It seems more likely that there is a documentation
> error, or a bug in handling widgets which share a constraint being
> destroyed out of order.
>
> I'm afraid finding someone who cares greatly about libXt will be hard,
> but do you think it would now be possible to craft a test case which
> demonstrates the problem?

I was considering it, as ncview is likely not the only program
with this potential problem.
Time to learn a bit of X programming...

Regards
Marco



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-22 11:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-20  9:57 X widget question Marco Atzeri
2016-03-22 10:19 ` Jon Turney
2016-03-22 11:30   ` Marco Atzeri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).