Pt_ARG_POINTS

If I set the Pt_ARG_POINTS resource to 2 points, and provide a buffer of 2
points, Photon crashes. Looks like it tries to access a third point in the
buffer, because if I make the buffer 3 points big, it works fine.

No problem when using more than 2 points.

This problem occurs since 6.1
Markus

Markus Loffler <loffler@ces.clemson.edu> wrote:

If I set the Pt_ARG_POINTS resource to 2 points, and provide a buffer of 2
points, Photon crashes. Looks like it tries to access a third point in the
buffer, because if I make the buffer 3 points big, it works fine.

1 What widget? :slight_smile:

2 When you say “Photon crashes”, do you actually mean Photon?

\

Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

All widgets derived from PtGraphic.
Sorry for my sloppy language, I mean of course my program crashes while
calling the PtSetResource()
Markus


“Wojtek Lerch” <wojtek@qnx.com> wrote in message
news:9i4op6$ju5$1@nntp.qnx.com

Markus Loffler <> loffler@ces.clemson.edu> > wrote:
If I set the Pt_ARG_POINTS resource to 2 points, and provide a buffer of
2
points, Photon crashes. Looks like it tries to access a third point in
the
buffer, because if I make the buffer 3 points big, it works fine.

1 What widget? > :slight_smile:

2 When you say “Photon crashes”, do you actually mean Photon?

\

Wojtek Lerch (> wojtek@qnx.com> ) QNX Software Systems Ltd.

Markus Loffler <loffler@ces.clemson.edu> wrote:

All widgets derived from PtGraphic.
Sorry for my sloppy language, I mean of course my program crashes while
calling the PtSetResource()

I just put together a test app whose setup function looks like this:

PhPoint_t const pts[] = { { 10, 10 }, { 20, 20 } };

PtSetResource( ABW_pixel, Pt_ARG_POINTS, pts, 2 );
PtSetResource( ABW_poly, Pt_ARG_POINTS, pts, 2 );
PtSetResource( ABW_line, Pt_ARG_POINTS, pts, 2 );
PtSetResource( ABW_ellipse, Pt_ARG_POINTS, pts, 2 );
PtSetResource( ABW_bezier, Pt_ARG_POINTS, pts, 2 );

It does not crash. Is your code different from mine?

\

Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

The original program was too big, so I wrote a little test program.
Strange, this time it does not crash, but it does not display any window. If
you uncomment the last (0, 0) point, it works fine.
Do you get the same results?
Markus


#include <Pt.h>

main(int argc, char *argv[])
{
PtArg_t arg[5];
PtWidget_t *window;

if ((window = PtAppInit(0, 0, 0, 0, NULL)) == NULL)
exit(-1);

PhPoint_t const pts[] = { { 10, 10 }, { 20, 20} /, { 0, 0 }/ };
PtWidget_t *rect = PtCreateWidget(PtRect, window, 0, arg);

PtSetResource(rect, Pt_ARG_POINTS, pts, 2);

PtRealizeWidget(window);

PtMainLoop();
}


“Wojtek Lerch” <wojtek@qnx.com> wrote in message
news:9i4tjt$mjn$1@nntp.qnx.com

Markus Loffler <> loffler@ces.clemson.edu> > wrote:
All widgets derived from PtGraphic.
Sorry for my sloppy language, I mean of course my program crashes while
calling the PtSetResource()

I just put together a test app whose setup function looks like this:

PhPoint_t const pts[] = { { 10, 10 }, { 20, 20 } };

PtSetResource( ABW_pixel, Pt_ARG_POINTS, pts, 2 );
PtSetResource( ABW_poly, Pt_ARG_POINTS, pts, 2 );
PtSetResource( ABW_line, Pt_ARG_POINTS, pts, 2 );
PtSetResource( ABW_ellipse, Pt_ARG_POINTS, pts, 2 );
PtSetResource( ABW_bezier, Pt_ARG_POINTS, pts, 2 );

It does not crash. Is your code different from mine?

\

Wojtek Lerch (> wojtek@qnx.com> ) QNX Software Systems Ltd.

begin 666 graphic.cpp
M(VEN8VQU9&4@/%!T+F@^#0H-“FUA:6XH:6YT(&%R9V,L(&-H87(@F%R9W9;
M72D-“GL-“B @(%!T07)G7W0@(” @(” @(&%R9ULU73L-“B @(%!T5VED9V5T
M7W0@(” @("IW:6YD;W<[#0H-“B @(&EF(”@H=VEN9&]W(#T@4’1!<’!);FET
M
# L(# L(# L(# L($Y53$PI2 ]/2!.54Q,0T(" @(" @97AI="@M,2D[
M#0H)#0H@("!0:%!O:6YT7W0@8V]N<W0@<'1S6UT@/2![('L@,3 L(#$P('TL
M('L@,C L(#(P?2 O
BP@>R P+” P(‘TJ+R!].PT*(" @4’17:61G971?=" J
M<F5C=" ](%!T0W)E871E5VED9V5T*%!T4F5C=“P@=VEN9&]W+” P+"!A<F<I
M.PT*#0H@("!0=%-E=%)E<V]U<F-E*’)E8W0L(%!T7T%21U]03TE.5%,L(’!T
M<RP@,BD[#0H@(" -"B @(%!T4F5A;&EZ95=I9&=E=“AW:6YD;W<I.PT*#0H@
4(”!0=$UA:6Y,;V]P*"D[#0I]#0H
end

Markus Loffler <loffler@ces.clemson.edu> wrote:

The original program was too big, so I wrote a little test program.
Strange, this time it does not crash, but it does not display any window. If
you uncomment the last (0, 0) point, it works fine.
Do you get the same results?

Yes, unless I turn on optimization. It seems to be a compiler bug that
makes the initialization of pts set window to NULL. It even does it if
you add “printf(”%p\n",window);" before and after the line that defines
pts[].

Pretty scary, isn’t it?

#include <Pt.h

main(int argc, char *argv[])
{
PtArg_t arg[5];
PtWidget_t *window;

if ((window = PtAppInit(0, 0, 0, 0, NULL)) == NULL)
exit(-1);

printf( “%p\n”, window );

PhPoint_t const pts[] = { { 10, 10 }, { 20, 20} /, { 0, 0 }/ };
printf( “%p\n”, window );



PtWidget_t *rect = PtCreateWidget(PtRect, window, 0, arg);

PtSetResource(rect, Pt_ARG_POINTS, pts, 2);

PtRealizeWidget(window);

PtMainLoop();
}


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.