I wrote a non-phab application which create a region
After PtInit(), I call name_attach which terminates with a SIGSEGV.
Why?
Alain.
I wrote a non-phab application which create a region
After PtInit(), I call name_attach which terminates with a SIGSEGV.
Why?
Alain.
Alain Bonnefoy wrote:
I wrote a non-phab application which create a region
After PtInit(), I call name_attach which terminates with a SIGSEGV.
Why?
I don’t see how calling PtInit() could make name_attach() crash. I
don’t think name_attach() is supposed to crash unless you pass a bad
pointer to it. Or your heap is corrupted. Or there’s a bug in
name_attach()…
Are you calling name_attach() right after PtInit()? Does the crash go
away if you remove the call to PtInit()?
The following program works for me. Does it not work for you?
#include <stdio.h>
#include <sys/iofunc.h>
#include <sys/dispatch.h>
#include <Pt.h>
int main( void ) {
if ( PtInit(NULL) )
perror(“PtInit”);
else
if ( name_attach( NULL, “foo”, 0 ) == NULL )
perror( “name_attach” );
else {
puts( “Success!” );
return 0;
}
return 1;
}
After some tests, I discovered that the crash has no relationship with
PtInit but a RtTimerCreate call.
My code is:
…
if (PtInit(cServeurPhoton) == -1)
exit(EXIT_FAILURE);
if ((blink_timer = RtTimerCreate(CLOCK_REALTIME, getprio(0),
timer_reply, NULL)) == NULL) {
printf(“error %s\n”, strerror(errno));
PtExit(EXIT_FAILURE);
}
if ((attach = name_attach(NULL, __progname, 0)) == NULL) {
printf(“error %s\n”, strerror(errno));
PtExit(EXIT_FAILURE);
}
…
If I call name_attach() before RtTimerCreate(), I don’t get any SIGSEGV.
Any idea?
Alain.
Wojtek Lerch wrote:
Alain Bonnefoy wrote:
I wrote a non-phab application which create a region
After PtInit(), I call name_attach which terminates with a SIGSEGV.
Why?I don’t see how calling PtInit() could make name_attach() crash. I
don’t think name_attach() is supposed to crash unless you pass a bad
pointer to it. Or your heap is corrupted. Or there’s a bug in
name_attach()…Are you calling name_attach() right after PtInit()? Does the crash go
away if you remove the call to PtInit()?The following program works for me. Does it not work for you?
#include <stdio.h
#include <sys/iofunc.h
#include <sys/dispatch.h
#include <Pt.hint main( void ) {
if ( PtInit(NULL) )
perror(“PtInit”);
else
if ( name_attach( NULL, “foo”, 0 ) == NULL )
perror( “name_attach” );
else {
puts( “Success!” );
return 0;
}
return 1;
}
Alain Bonnefoy wrote:
After some tests, I discovered that the crash has no relationship with
PtInit but a RtTimerCreate call.
It’s a bug in name_attach(). It’s fixed in 6.3, but the fix won’t buy
you much – the bug is in error handling, and instead of crashing, the
fixed name_attach() returns EBUSY…
The real problem is that RtTimerCreate() uses PtAppAddInput()
internally, and both PtAppAddInput() and name_attach() want to create
channels with a combination of flags that the kernel only allows in one
channel per process. If you search for name_attach in the helpviewer
docs, most of the hits will point you to the explanation of this problem
and possible workarounds.
My code is:
…if (PtInit(cServeurPhoton) == -1)
exit(EXIT_FAILURE);
if ((blink_timer = RtTimerCreate(CLOCK_REALTIME, getprio(0),
timer_reply, NULL)) == NULL) {
printf(“error %s\n”, strerror(errno));
PtExit(EXIT_FAILURE);
}if ((attach = name_attach(NULL, __progname, 0)) == NULL) {
printf(“error %s\n”, strerror(errno));
PtExit(EXIT_FAILURE);
}…
If I call name_attach() before RtTimerCreate(), I don’t get any SIGSEGV.
Any idea?
Alain.
Wojtek Lerch wrote:
Alain Bonnefoy wrote:I wrote a non-phab application which create a region
After PtInit(), I call name_attach which terminates with a SIGSEGV.
Why?
I don’t see how calling PtInit() could make name_attach() crash. I
don’t think name_attach() is supposed to crash unless you pass a bad
pointer to it. Or your heap is corrupted. Or there’s a bug in
name_attach()…
Are you calling name_attach() right after PtInit()? Does the crash go
away if you remove the call to PtInit()?
The following program works for me. Does it not work for you?
#include <stdio.h
#include <sys/iofunc.h
#include <sys/dispatch.h
#include <Pt.h
int main( void ) {
if ( PtInit(NULL) )
perror(“PtInit”);
else
if ( name_attach( NULL, “foo”, 0 ) == NULL )
perror( “name_attach” );
else {
puts( “Success!” );
return 0;
}
return 1;
}
\