System crash

/*
This program , based on example from Watcom library, crashes my computer
! Why ?
*/

#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <sys/proxy.h>
#include <sys/kernel.h>
#include <stdlib.h>

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
printf( “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
printf( “Unable to attach timer.” );
return EXIT_FAILURE;
}

timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = 100000000L;
timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_nsec = 100000000L;
timer_settime( id, TIMER_ABSTIME, &timer, NULL );

printf(“You should see this line!\n”);
}

“David V.” <davidv@elisra.com> wrote in message
news:3C1E0AE2.B63C6229@elisra.com

/*
This program , based on example from Watcom library, crashes my computer
! Why ?
*/

Crashed the computer, what sort of crash?

I compile and ran this code with no problem.

Note that I think it would be best to memset event
to 0.

What version of QNX are you using?


#include <stdio.h
#include <signal.h
#include <time.h
#include <sys/proxy.h
#include <sys/kernel.h
#include <stdlib.h

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
printf( “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
printf( “Unable to attach timer.” );
return EXIT_FAILURE;
}

timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = 100000000L;
timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_nsec = 100000000L;
timer_settime( id, TIMER_ABSTIME, &timer, NULL );

printf(“You should see this line!\n”);
}

The system is QNX4 4.25J.
The problem is in function timer_settime.
The crash is: the computer stops working.
I have the same efect on other computers.

Mario Charest wrote:

“David V.” <> davidv@elisra.com> > wrote in message
news:> 3C1E0AE2.B63C6229@elisra.com> …
/*
This program , based on example from Watcom library, crashes my computer
! Why ?
*/


Crashed the computer, what sort of crash?

I compile and ran this code with no problem.

Note that I think it would be best to memset event
to 0.

What version of QNX are you using?

#include <stdio.h
#include <signal.h
#include <time.h
#include <sys/proxy.h
#include <sys/kernel.h
#include <stdlib.h

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
printf( “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
printf( “Unable to attach timer.” );
return EXIT_FAILURE;
}

timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = 100000000L;
timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_nsec = 100000000L;
timer_settime( id, TIMER_ABSTIME, &timer, NULL );

printf(“You should see this line!\n”);
}

“David V.” <davidv@elisra.com> wrote in message
news:3C1E115D.9D1074E3@elisra.com

The system is QNX4 4.25J.
The problem is in function timer_settime.
The crash is: the computer stops working.
I have the same efect on other computers.

I’m using 4.25J as well. How did you compile it. I used
cc sample.c (no option).

Do you get a core dump? The computer freezes?
Is the num lock key still working (led blinks)?

Why do you say the problem is in timer_settime()?



Mario Charest wrote:

“David V.” <> davidv@elisra.com> > wrote in message
news:> 3C1E0AE2.B63C6229@elisra.com> …
/*
This program , based on example from Watcom library, crashes my
computer
! Why ?
*/


Crashed the computer, what sort of crash?

I compile and ran this code with no problem.

Note that I think it would be best to memset event
to 0.

What version of QNX are you using?

#include <stdio.h
#include <signal.h
#include <time.h
#include <sys/proxy.h
#include <sys/kernel.h
#include <stdlib.h

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
printf( “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
printf( “Unable to attach timer.” );
return EXIT_FAILURE;
}

timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = 100000000L;
timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_nsec = 100000000L;
timer_settime( id, TIMER_ABSTIME, &timer, NULL );

printf(“You should see this line!\n”);
}

The make command I uses is : make sample.
I run this program on 5 computers on my network many times using ‘//node
sample’ every time rebooting after crash (freeze). By the way, I run
automap.
After resetting the network switch the problem disappeared !
I see this issue closed meanwhile.
Thanks.



Mario Charest wrote:

“David V.” <> davidv@elisra.com> > wrote in message
news:> 3C1E115D.9D1074E3@elisra.com> …
The system is QNX4 4.25J.
The problem is in function timer_settime.
The crash is: the computer stops working.
I have the same efect on other computers.


I’m using 4.25J as well. How did you compile it. I used
cc sample.c (no option).

Do you get a core dump? The computer freezes?
Is the num lock key still working (led blinks)?

Why do you say the problem is in timer_settime()?

Mario Charest wrote:

“David V.” <> davidv@elisra.com> > wrote in message
news:> 3C1E0AE2.B63C6229@elisra.com> …
/*
This program , based on example from Watcom library, crashes my
computer
! Why ?
*/


Crashed the computer, what sort of crash?

I compile and ran this code with no problem.

Note that I think it would be best to memset event
to 0.

What version of QNX are you using?

#include <stdio.h
#include <signal.h
#include <time.h
#include <sys/proxy.h
#include <sys/kernel.h
#include <stdlib.h

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
printf( “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
printf( “Unable to attach timer.” );
return EXIT_FAILURE;
}

timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = 100000000L;
timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_nsec = 100000000L;
timer_settime( id, TIMER_ABSTIME, &timer, NULL );

printf(“You should see this line!\n”);
}

David V. <davidv@elisra.com> wrote:

/*
This program , based on example from Watcom library, crashes my computer
! Why ?
*/

I’ve reproduced this and issued a PR (problem report) against it.

What you’re doing, though, is a bit strange… you are starting
a timer counting from a fraction of a second after January 1st,
1970 UTC. Not generally what you want to do.

Change the line:

timer_settime( id, TIMER_ABSTIME, &timer, NULL );

to:
timer_settime( id, 0, &timer, NULL );

And you won’t have any problems at all.

-David

#include <stdio.h
#include <signal.h
#include <time.h
#include <sys/proxy.h
#include <sys/kernel.h
#include <stdlib.h

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
printf( “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
printf( “Unable to attach timer.” );
return EXIT_FAILURE;
}

timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = 100000000L;
timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_nsec = 100000000L;

printf(“You should see this line!\n”);
}


QNX Training Services
I do not answer technical questions by email.

David Gibbs <dagibbs@qnx.com> wrote:

David V. <> davidv@elisra.com> > wrote:
/*
This program , based on example from Watcom library, crashes my computer
! Why ?
*/

I’ve reproduced this and issued a PR (problem report) against it.

(The crash dropped Proc32 4.25J into the debugger. That should
not happen.)

-David

QNX Training Services
I do not answer technical questions by email.

“David V.” <davidv@elisra.com> wrote in message
news:3C1E27E1.9E191EA7@elisra.com

The make command I uses is : make sample.
I run this program on 5 computers on my network many times using ‘//node
sample’ every time rebooting after crash (freeze). By the way, I run
automap.
After resetting the network switch the problem disappeared !

I don’t see how resetting the network switch could affect a timer
related issue. At any rate check David’s post.

I see this issue closed meanwhile.
Thanks.



Mario Charest wrote:

“David V.” <> davidv@elisra.com> > wrote in message
news:> 3C1E115D.9D1074E3@elisra.com> …
The system is QNX4 4.25J.
The problem is in function timer_settime.
The crash is: the computer stops working.
I have the same efect on other computers.


I’m using 4.25J as well. How did you compile it. I used
cc sample.c (no option).

Do you get a core dump? The computer freezes?
Is the num lock key still working (led blinks)?

Why do you say the problem is in timer_settime()?

Mario Charest wrote:

“David V.” <> davidv@elisra.com> > wrote in message
news:> 3C1E0AE2.B63C6229@elisra.com> …
/*
This program , based on example from Watcom library, crashes my
computer
! Why ?
*/


Crashed the computer, what sort of crash?

I compile and ran this code with no problem.

Note that I think it would be best to memset event
to 0.

What version of QNX are you using?

#include <stdio.h
#include <signal.h
#include <time.h
#include <sys/proxy.h
#include <sys/kernel.h
#include <stdlib.h

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
printf( “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
printf( “Unable to attach timer.” );
return EXIT_FAILURE;
}

timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = 100000000L;
timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_nsec = 100000000L;
timer_settime( id, TIMER_ABSTIME, &timer, NULL );

printf(“You should see this line!\n”);
}
\

Sorry, problem with english.

Hi Mario!
Hi David !

David!
Your problem is in “TIMER_ABSTIME” flag in function
timer_settime(). If you want to “Receive()” timer ticks from proxy
associated with timer every 100000000L nsec, change flag to zero. It work
fine.

//
timer_settime( id, 0, &timer, NULL );
//

If you need to use “TIMER_ABSTIME” flag, please describe your task with
more details.
Then we using “TIMER_ABSTIME” flag , the
value “timer.it_value.tv_sec” must be in future on sense( bigger then result
of function “time()”), but in your code it is 0.
And it is the source of very interesting problem, possibly QNX4 bug.

Mario !
I compile and run code from David with no problem too.
BUT!
Then I added at the end of David code simple Receive(),
I have the same problem: the computer stops working( may be David loss
some line at the end of code?).
Simple “sleep” have same effect. ( See SECTION 1. )
QNX4 crashed!? It is imposible.

I have trying to localize the problem.
See rezults in SECTION 2.
May be it is my stupid way to set “timer.it_value.tv_sec”
in the past, set very small “timer.it_interval” and simultaneously set
TIMER_ABSTIME flag in timer_settime(0), but it is not must fully
blocked OS. ( I am running test as simple user, not root !)
May be I mistakes? It is will be very good to hear QNX experts.

“David V.” <> davidv@elisra.com> > wrote in message
news:> 3C1E115D.9D1074E3@elisra.com> …
The system is QNX4 4.25J.
The problem is in function timer_settime.
The crash is: the computer stops working.
I have the same efect on other computers.


I’m using 4.25J as well. How did you compile it. I used
cc sample.c (no option).

Do you get a core dump? The computer freezes?
Is the num lock key still working (led blinks)?

Why do you say the problem is in timer_settime()?



Mario Charest wrote:

“David V.” <> davidv@elisra.com> > wrote in message
news:> 3C1E0AE2.B63C6229@elisra.com> …
/*
This program , based on example from Watcom library, crashes my
computer
! Why ?
*/


Crashed the computer, what sort of crash?

I compile and ran this code with no problem.

Note that I think it would be best to memset event
to 0.

What version of QNX are you using?

#include <stdio.h
#include <signal.h
#include <time.h
#include <sys/proxy.h
#include <sys/kernel.h
#include <stdlib.h

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
printf( “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
printf( “Unable to attach timer.” );
return EXIT_FAILURE;
}

timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = 100000000L;
timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_nsec = 100000000L;
timer_settime( id, TIMER_ABSTIME, &timer, NULL );

printf(“You should see this line!\n”);
}


\

QNX 4.25L ( cc test.c, on QNX console, simple user)

SECTION 1
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <sys/proxy.h>
#include <sys/kernel.h>
#include <stdlib.h>

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
printf( “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
printf( “Unable to attach timer.” );
return EXIT_FAILURE;
}

timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = 100000000L;
timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_nsec = 100000000L;
timer_settime( id, TIMER_ABSTIME, &timer, NULL );
Receive(0,0,0);
// sleep(1);
printf(“You should see this line!\n”);
return 0;
}

SECTION 2

#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <sys/proxy.h>
#include <sys/kernel.h>
#include <stdlib.h>

int main( void )
{
pid_t proxy;
timer_t id, i;
struct itimerspec timer;
struct sigevent event;


/** Added by Shr. */
/
Sorry. English not fully supported. /
pid_t pid;
time_t cur_time, back_time;
int rc, counter=0;
long seconds_to_back=2
65535000L;
long interval=5L;
/*******************/

/* All “printf” replaced on “fprintf” */

/* Get a proxy for the timer to kick */
proxy = qnx_proxy_attach( 0, 0, 0, -1 );
if( proxy == -1 ) {
fprintf(stderr, “Unable to attach proxy.” );
return EXIT_FAILURE;
}

/* Attach to the timer */
event.sigev_signo = -proxy;
id = timer_create( CLOCK_REALTIME, &event );
if( id == -1 ) {
fprintf(stderr, “Unable to attach timer.” );
return EXIT_FAILURE;
}

/** Added by Shr. */
cur_time=time(NULL);
back_time=cur_time-seconds_to_back; /
stupid action ? Yes. /
/
******************/

/** Replaced by Shr. **/
// timer.it_value.tv_sec = 0L;
timer.it_value.tv_sec = back_time;
// timer.it_value.tv_nsec = 100000000L;
timer.it_value.tv_nsec = 0L; // using only seconds
// timer.it_interval.tv_sec = 0L;
timer.it_interval.tv_sec = interval;
// timer.it_interval.tv_nsec = 100000000L;
timer.it_interval.tv_nsec = 0L;

fprintf(stderr,"\n QNX4 (4.25L) now fully blocked ( OS time stopped,
NumLock not flushed, etc. \n Please wait … \n");
rc=timer_settime( id, TIMER_ABSTIME, &timer, NULL );
sleep(1); //?!
fprintf(stderr,"\n BUT QNX4 LIVE! (timer_settime rc=%d) \n", rc);
sleep(2); //?!
/* Then seconds_to_back is huge ( back_time ~ 0) and
interval very small ( using tv_nsec ) QNX4 may be blocked very very
long time /


/
Added by Shr. /
/
Reseach section /
while(counter < 102 /
? /)
{
/
after long( processor speed dependent?) pause receiving at “one
moment”
99 times from " timer proxy", then normally , every “tv_sec”
seconds interval.*/
pid = Receive(0,0,0);
counter++;
fprintf(stderr," pid is %d counter is %d\n", pid, counter);
}

fprintf(stderr,“You should see this line!\n”);

/** Added by Shr. /
return EXIT_SUCCESS;
/
******************/

}


Shr.