Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Threaded perl 5.8.0 for Solaris

by Anonymous Monk
on Aug 28, 2003 at 13:17 UTC ( [id://287348]=note: print w/replies, xml ) Need Help??


in reply to Threaded perl 5.8.0 for Solaris

How about some code? XS is tricky, and memory faults can spring up real easy if you're not careful. See "Safely Storing Static Data in XS" in perlxs for some hints.

Replies are listed 'Best First'.
Re: Re: Threaded perl 5.8.0 for Solaris
by asarih (Hermit) on Aug 28, 2003 at 14:36 UTC
    Well, here's the XS routine that's causing the memory fault. Like I said, routine works fine for non-threaded perl.
    double __call( sv_class, sv_path, sv_input ) SV * sv_class SV * sv_path SV * sv_input CODE: char *class = SvPV( sv_class, PL_na ); char *path = SvPV( sv_path, PL_na ); double input = SvNV( sv_input ); int fd; door_arg_t arg; double output; fd = open(path, O_RDWR); arg.data_ptr = (char *) &input; arg.data_size = sizeof(double); arg.desc_ptr = NULL; arg.desc_num = 0; arg.rbuf = (char *) &output; arg.rsize = sizeof(double); if ( door_call(fd, &arg) == 0 ) { RETVAL = output; } else { printf("ERRNO: %d\n",errno); RETVAL = -1; } OUTPUT: RETVAL
      Please know that I have no experience with Solaris, or threaded applications using XS to speak of. That said, it seems you are leaking file descriptors, as you are doing:
      fd = open(path, O_RDWR);
      and you're not closing the file while the "int fd" does go out of scope. This is XS, not Perl! The file will not be automatically closed when its "handle" is destroyed. This may or may not be related to what you're seeing, though.

      Liz

        Thanks for the reminder, Liz. I put close(fd); after door_call(), but the error insists (on threaded perl, that is).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://287348]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found