XtVaCreateManagedWidget crash - Motif

This is a discussion on XtVaCreateManagedWidget crash - Motif ; Hi all, I have been involved in porting our application from Solaris 8 to Solaris 10 and also moving it to 32-bit to a 64-bit architecture. System details SunOS 5.10 Generic sun4u sparc SUNW,Sun-Fire-V210 Motif Version 2.1.0 The program seems ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: XtVaCreateManagedWidget crash

  1. XtVaCreateManagedWidget crash

    Hi all,
    I have been involved in porting our application from Solaris 8 to
    Solaris 10 and also moving it to 32-bit to a 64-bit architecture.

    System details
    SunOS 5.10 Generic sun4u sparc SUNW,Sun-Fire-V210

    Motif Version 2.1.0

    The program seems to be crashing in a function call to
    XtVaCreateManagedWidget

    Stack Trace
    ffffffff7d547c5c _XtCompileCallbackList (201, 0, 2c, ffffffff7d669e90,
    100214d20, 3) + 4
    ffffffff7d520b84 CompileCallbacks (100215ca0, ffffffff7d669e90,
    100214d38, ffffffff7d51df38, ffffffff7d664db0, 1) + 74
    ffffffff7d51c6e0 xtCreate (100215ca0, ffffffff7fffd980,
    ffffffff7ecf23c0, 100200510, 100185df0, ffffffff7fffd970) + 1f0
    ffffffff7d525bc0 _XtCreateWidget (100252520, ffffffff7ecf23c0,
    100200510, 0, 0, 100253d60) + 278
    ffffffff7d5444b8 _XtVaCreateWidget (100252520, ffffffff7ecf23c0,
    100200510, ffffffff7fffe0b8, 1, 1) + 38
    ffffffff7d544784 XtVaCreateManagedWidget (100252520, ffffffff7ecf23c0,
    100200510, ffffffff7d55d60a, 12070c, ffffffff7dc7d008) + fc
    ffffffff7ebc9f2c __1cRGuiTopLevelWindowGcreate6MpnK_WidgetRec__v_
    (ffffffff7d55e0e1, ffffffff7d55d60a, 20, 0, 0, 0) + 324
    ffffffff7ebc9440 __1cRGuiTopLevelWindow2t5B6Mhpkc2pv_v_ (100200180, 0,
    10017e758, 0, 0, 1) + c0
    000000010000ccc0 __1cHyyparse6F_i_ (100128890, 7b, 0, 100132e70, 0,
    100132e70) + 1118
    000000010000b308 main (2, ffffffff7fffef78, ffffffff7fffef90,
    ffffffff7c646a38, ffffffff7bb02980, ffffffff7bb029c0) + 4f8
    000000010000ad7c _start (0, 0, 0, 0, 0, 0) + 17c

    The function is

    void GuiTopLevelWindow::create(Widget uiparent)
    {
    HDISPLAY *hdisplay = HDISPLAYFromHandle(screen);
    UiDisplay *uidisplay = hdisplay->getUiDisplay();
    Atom WM_DELETE_WINDOW;

    if (created())
    return;

    Colormap cmap = (Colormap) GuiGetCmap (getScreen ());

    if (*title)
    {
    uiwidget = XtVaAppCreateShell(
    appl_class, resource, topLevelShellWidgetClass, uidisplay,
    XmNtitle, title,
    XmNdeleteResponse, XmDESTROY,
    XmNallowShellResize, True,
    XmNcolormap, cmap,
    NULL );
    }
    else
    {
    uiwidget = XtVaAppCreateShell(
    appl_class, resource, topLevelShellWidgetClass, uidisplay,
    // XmNdeleteResponse, XmDO_NOTHING,
    XmNdeleteResponse, XmDESTROY,
    XmNallowShellResize, True,
    XmNcolormap, cmap,
    NULL );
    }

    // A little something so that we can use editres
    XtAddEventHandler( uiwidget, (EventMask) 0, True,
    (XtEventHandler) _XEditResCheckMessages, NULL);

    // For iconification
    XtAddEventHandler(uiwidget, StructureNotifyMask, False, cb_minmax,
    this);
    WM_DELETE_WINDOW = XmInternAtom( XtDisplay(uiwidget),
    "WM_DELETE_WINDOW", False );
    wmDeleteAtom = (void*) WM_DELETE_WINDOW;
    XmAddWMProtocolCallback( uiwidget, WM_DELETE_WINDOW, cb_destroy, this
    );

    uiframe = XtVaCreateManagedWidget(
    resource, xfbSequenceWidgetClass, uiwidget,
    XmNcolormap, cmap,
    NULL );

    applyMargin();
    applyResize();

    setDefaultDragIcon(uiwidget);

    GuiBase::create( uiwidget );
    }


    This works fine under Solaris 8 with 32-bit compilation. I could see
    similar problems posted but no valid response that describe a solution
    to my problem.
    There seemed to e bug in Motif 2.1 and was fixed for IRIX. Is there
    some patch of Motif2.1 available for SOlaris 10 that I can use to
    resolve this issue.
    Any help would be appreciated. I am under a bit of pressure to finish
    off this porting exercise ....


  2. Re: XtVaCreateManagedWidget crash

    I see this all the time on 64-bit ports.

    Try changing NULL to (void*)0 or (char*)0 to make sure it's passed
    through properly. Otherwise you're at the mercy of your compiler or
    compiler switches.

  3. Re: XtVaCreateManagedWidget crash


    ST wrote:
    > I see this all the time on 64-bit ports.
    >
    > Try changing NULL to (void*)0 or (char*)0 to make sure it's passed
    > through properly. Otherwise you're at the mercy of your compiler or
    > compiler switches.


    thanks for the suggestion. But even after i passed in (void *)0 instead
    of NULL, it still crashes. Any further ideas ?
    The order in which the X libraries are included are -lXm -lXmu -lXt
    -lX11


  4. Re: XtVaCreateManagedWidget crash


    "@sax" wrote in message
    news:1158672111.129553.176970@i3g2000cwc.googlegro ups.com...
    > Hi all,
    > I have been involved in porting our application from Solaris 8 to
    > Solaris 10 and also moving it to 32-bit to a 64-bit architecture.
    >
    > System details
    > SunOS 5.10 Generic sun4u sparc SUNW,Sun-Fire-V210
    >
    > Motif Version 2.1.0
    >
    > The program seems to be crashing in a function call to
    > XtVaCreateManagedWidget
    >
    > Stack Trace
    > ffffffff7d547c5c _XtCompileCallbackList (201, 0, 2c, ffffffff7d669e90,
    > 100214d20, 3) + 4
    > ffffffff7d520b84 CompileCallbacks (100215ca0, ffffffff7d669e90,
    > 100214d38, ffffffff7d51df38, ffffffff7d664db0, 1) + 74
    > ffffffff7d51c6e0 xtCreate (100215ca0, ffffffff7fffd980,
    > ffffffff7ecf23c0, 100200510, 100185df0, ffffffff7fffd970) + 1f0
    > ffffffff7d525bc0 _XtCreateWidget (100252520, ffffffff7ecf23c0,
    > 100200510, 0, 0, 100253d60) + 278
    > ffffffff7d5444b8 _XtVaCreateWidget (100252520, ffffffff7ecf23c0,
    > 100200510, ffffffff7fffe0b8, 1, 1) + 38
    > ffffffff7d544784 XtVaCreateManagedWidget (100252520, ffffffff7ecf23c0,
    > 100200510, ffffffff7d55d60a, 12070c, ffffffff7dc7d008) + fc
    > ffffffff7ebc9f2c __1cRGuiTopLevelWindowGcreate6MpnK_WidgetRec__v_
    > (ffffffff7d55e0e1, ffffffff7d55d60a, 20, 0, 0, 0) + 324
    > ffffffff7ebc9440 __1cRGuiTopLevelWindow2t5B6Mhpkc2pv_v_ (100200180, 0,
    > 10017e758, 0, 0, 1) + c0
    > 000000010000ccc0 __1cHyyparse6F_i_ (100128890, 7b, 0, 100132e70, 0,
    > 100132e70) + 1118
    > 000000010000b308 main (2, ffffffff7fffef78, ffffffff7fffef90,
    > ffffffff7c646a38, ffffffff7bb02980, ffffffff7bb029c0) + 4f8
    > 000000010000ad7c _start (0, 0, 0, 0, 0, 0) + 17c
    >
    > The function is
    >
    > void GuiTopLevelWindow::create(Widget uiparent)
    > {
    > HDISPLAY *hdisplay = HDISPLAYFromHandle(screen);
    > UiDisplay *uidisplay = hdisplay->getUiDisplay();
    > Atom WM_DELETE_WINDOW;
    >
    > if (created())
    > return;
    >
    > Colormap cmap = (Colormap) GuiGetCmap (getScreen ());
    >
    > if (*title)
    > {
    > uiwidget = XtVaAppCreateShell(
    > appl_class, resource, topLevelShellWidgetClass, uidisplay,
    > XmNtitle, title,
    > XmNdeleteResponse, XmDESTROY,
    > XmNallowShellResize, True,
    > XmNcolormap, cmap,
    > NULL );
    > }
    > else
    > {
    > uiwidget = XtVaAppCreateShell(
    > appl_class, resource, topLevelShellWidgetClass, uidisplay,
    > // XmNdeleteResponse, XmDO_NOTHING,
    > XmNdeleteResponse, XmDESTROY,
    > XmNallowShellResize, True,
    > XmNcolormap, cmap,
    > NULL );
    > }
    >
    > // A little something so that we can use editres
    > XtAddEventHandler( uiwidget, (EventMask) 0, True,
    > (XtEventHandler) _XEditResCheckMessages, NULL);
    >
    > // For iconification
    > XtAddEventHandler(uiwidget, StructureNotifyMask, False, cb_minmax,
    > this);
    > WM_DELETE_WINDOW = XmInternAtom( XtDisplay(uiwidget),
    > "WM_DELETE_WINDOW", False );
    > wmDeleteAtom = (void*) WM_DELETE_WINDOW;
    > XmAddWMProtocolCallback( uiwidget, WM_DELETE_WINDOW, cb_destroy, this
    > );
    >
    > uiframe = XtVaCreateManagedWidget(
    > resource, xfbSequenceWidgetClass, uiwidget,
    > XmNcolormap, cmap,
    > NULL );
    >
    > applyMargin();
    > applyResize();
    >
    > setDefaultDragIcon(uiwidget);
    >
    > GuiBase::create( uiwidget );
    > }
    >
    >
    > This works fine under Solaris 8 with 32-bit compilation. I could see
    > similar problems posted but no valid response that describe a solution
    > to my problem.
    > There seemed to e bug in Motif 2.1 and was fixed for IRIX. Is there
    > some patch of Motif2.1 available for SOlaris 10 that I can use to
    > resolve this issue.
    > Any help would be appreciated. I am under a bit of pressure to finish
    > off this porting exercise ....
    >


    This is likely caused by a memory corruption caused elsewhere.
    One place to check: make sure all uses of XtVetValues or XtVaGetValues
    are done correctly - that is, maks sure that the data type is exactly
    correct.
    One I see often is something like this:

    int value;

    value = xxxx;
    n = 0;
    XtSetArg( arg[n], XmNuserData, value ); n++
    XtSetValue( w, arg, n);

    /* then later :*/

    int val;
    XtVaGetValues( w, XmNuserData, &val, NULL);

    This usually happens to work on 32-bit platforms, but will not work
    on most 64-bit platforms. That is because XmNuserData is of type
    XtPointer, which happens to be the same size as an int on many 32-bit
    platforms. But on 64-bit platforms, a pointer is 64 bits, but an int
    is probably still 32-bits. Thus the getValues call clobbers something
    when it tries to stuff 64 bits into the 32-bit address.

    The correct way:
    XtPointer p;
    int val;
    XtVaGetValues( w, XmNuserData, &p, NULL);
    val = (int)p;
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project







+ Reply to Thread