You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2001/12/14 05:19:51 UTC

passing through an existing foo.pm from xs

I'm not satisfied with autogenerated 
WrapXS/Apache/SubProcess/SubProcess.pm, since I need to require 
APR::PerlIO in it, and I don't really want to create the SubProcess.xs 
and Makefile.PL in xs/Apache/SubProcess/. Do you think it's OK for 
WrapXS to check whether foo.pm already exists and not to generate it if 
so and use the existing one.

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


found core file assumptions

Posted by Stas Bekman <st...@stason.org>.
Apache-Test assumes that any core file found under t was generated by 
httpd, (end suggests the gdb invoking command) which is wrong. I 
should've read the notice printed by gdb:

"Core was generated by `/home/stas/perl/ithread/bin/perl
/home/stas/apache.org/mp-subproc/t/TEST -confi"

This one was generated during t/TEST -config which is run by bin/perl.

so we may consider to do more investigation on every found core file. I 
plan to work on this and other core issue (automatic trace) soon.

Stas Bekman wrote:

> The problem I have is that I need to add 
> APACHE_TEST_CONFIGURE in the subprocess.pm and blows up on require 
> outside mod_perl with a weird core:
> 
> warning: core file may not match specified executable file.
> Core was generated by `/home/stas/perl/ithread/bin/perl 
> /home/stas/apache.org/mp-subproc/t/TEST -confi'.
> Program terminated with signal 11, Segmentation fault.
> #0  0x403ccbea in ?? ()
> (gdb) where
> #0  0x403ccbea in ?? ()
> #1  0x403bf6e2 in ?? ()
> #2  0x403db99f in ?? ()
> #3  0x403e2159 in ?? ()
> #4  0x403e1acc in ?? ()
> #5  0x400b7b10 in ?? ()
> #6  0x400965f9 in ?? ()
> #7  0x4003bf20 in ?? ()
> #8  0x4003baa2 in ?? ()
> #9  0x4004053b in ?? ()
> #10 0x4004000e in ?? ()
> #11 0x400798be in ?? ()
> #12 0x40074471 in ?? ()
> #13 0x4006850b in ?? ()
> #14 0x400f7ac8 in ?? ()
> #15 0x400f9b33 in ?? ()
> #16 0x400965f9 in ?? ()
> #17 0x4003aee6 in ?? ()
> #18 0x4003a981 in ?? ()
> #19 0x08049435 in ?? ()
> #20 0x401ea6a0 in ?? ()
> 
> Everything is updated, but it still gives me this weird trace... :(
> 
> _____________________________________________________________________
> Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
> http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
> mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
> http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
> For additional commands, e-mail: dev-help@perl.apache.org



-- 


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> you could have APR::SubProcess take the same args as the apr C
> functions.  and have an Apache::SubProcess wrapper that takes $r and
> passes the required values to the APR::SubProcess function(s).
> 
> i have no idea if APR::SubProcess would ever be useful outside of
> httpd.  but its better to expect the unexpected.
> 
> to answer the question at hand, if your functions take a request_rec,
> server_rec, or anything listed in apache_structures.map, then no, it
> cannot be used outside of httpd.

In fact it uses a bunch of ap_ functions, so it's no go. Going back to 
Apache::SubProcess.

I've no idea why the proc functions are not in apr :( They are written 
to be portable, but won't work without httpd.

Oh well,

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Doug MacEachern <do...@covalent.net>.
you could have APR::SubProcess take the same args as the apr C
functions.  and have an Apache::SubProcess wrapper that takes $r and
passes the required values to the APR::SubProcess function(s).

i have no idea if APR::SubProcess would ever be useful outside of
httpd.  but its better to expect the unexpected.

to answer the question at hand, if your functions take a request_rec,
server_rec, or anything listed in apache_structures.map, then no, it
cannot be used outside of httpd.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Stas Bekman <st...@stason.org>.
>>Otherwise how do you get subprocess_env?
>>
> 
> my $table = $r->subprocess_env;


[snip]


> if that doesn't help or make sense, give me more context.  what is the C
> prototype of the function that needs r->subprocess_env?

That's not what I meant. In APR::SubProcess::spawn_proc_prog I need to 
retrieve:

r->subprocess_env
r->server->timeout
r->filename

and may be more in the future. Currently I just pass $r to 
spawn_proc_prog() and do all the retrievals inside it. Otherwise I need 
to pass all these values from the caller.

In any case, is it important at all to try to make some of the 
interfaces to APR standalone?

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 14 Dec 2001, Stas Bekman wrote:
 
> I see what you mean. A module APR::Foo can be used outside of Apache if 
> it doesn't use any ap_ functins. But for example $r->subprocess_env 
> needs $r, which is Apache::Request. Doesn't it tie the module to Apache? 

huh?  no.

> Otherwise how do you get subprocess_env?

my $table = $r->subprocess_env;

APR::foo($table);

where the C prototype underneath APR::foo is:
void apr_foo(apr_table_t *table);

outside of httpd:

my $pool = APR::Pool->new;
my $table = APR::Table::make($pool, 10);

while (my($key,$val) = each %ENV) {
    $table->set($key, $val);
}

APR::foo($table);

if that doesn't help or make sense, give me more context.  what is the C
prototype of the function that needs r->subprocess_env?


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Fri, 14 Dec 2001, Stas Bekman wrote:
> 
> 
>>ok, that will work for APR::PerlIO, but APR::SubProcess needs $r/$s for
>>doing things like subprocess_env.
>>
> 
> $r->subprocess_env is an APR::Table, so no problem there.
> why does it need $s ?
> 
> if you're saying that something really needs a request_rec or server_rec
> then there must be an ap_ function in there somewhere.


I see what you mean. A module APR::Foo can be used outside of Apache if 
it doesn't use any ap_ functins. But for example $r->subprocess_env 
needs $r, which is Apache::Request. Doesn't it tie the module to Apache? 
Otherwise how do you get subprocess_env?






_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 14 Dec 2001, Stas Bekman wrote:

> ok, that will work for APR::PerlIO, but APR::SubProcess needs $r/$s for
> doing things like subprocess_env.

$r->subprocess_env is an APR::Table, so no problem there.
why does it need $s ?

if you're saying that something really needs a request_rec or server_rec
then there must be an ap_ function in there somewhere.




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

 > On Fri, 14 Dec 2001, Stas Bekman wrote:
 >
 >
 >>I've moved it to APR, but now I'm not sure if it's correct because both

 >>APR::PerlIO and Apache::Request need $r or $s, which makes them


oops, s/Apache::Request/APR::SubProcess/

 >>dependent on mod_perl. Or is it correct to say that $r/$s doesn't make
 >>the code dependent on mod_perl?
 >>
 >
 > just require an APR::Pool for the arg and pass in $r->pool when using
 > inside modperl.

ok, that will work for APR::PerlIO, but APR::SubProcess needs $r/$s for
doing things like subprocess_env.


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 14 Dec 2001, Stas Bekman wrote:
 
> I've moved it to APR, but now I'm not sure if it's correct because both 
> APR::PerlIO and Apache::Request need $r or $s, which makes them 
> dependent on mod_perl. Or is it correct to say that $r/$s doesn't make 
> the code dependent on mod_perl?

just require an APR::Pool for the arg and pass in $r->pool when using
inside modperl.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Stas Bekman <st...@stason.org>.
>>But since Apache::SubProcess could be used outside of mod_perl, this is 
>>probably not good enough.
>>
> 
> if that's the case, it should be APR::SubProcess.  it should only be named
> Apache::SubProcess if it references ap_ symbols.


I've moved it to APR, but now I'm not sure if it's correct because both 
APR::PerlIO and Apache::Request need $r or $s, which makes them 
dependent on mod_perl. Or is it correct to say that $r/$s doesn't make 
the code dependent on mod_perl?

 

But as you say since it uses apr_ it should be in APR::.


>>The problem I have is that I need to add 
>>APACHE_TEST_CONFIGURE in the subprocess.pm and blows up on require 
>>outside mod_perl with a weird core:
>>
> 
> looks like either a corrupt stack, dereferencing a NULL function pointer,
> or function pointer called with prototype mismatch.


now that I can get the trace I'll solve it :)

 
> could also be because the current APR::PerlIO cannot be used outside of
> httpd since it references modperl_global_get_pconf().
> but i would expect an 'unable to resolve symbol' error from the linker,
> not a wacky blowup like that.

This can explode only at run time and only if you don't supply $r/$s, 
since now I use modperl_sv2pool(aTHX_ sv); so it's something else. I'll 
figure out.

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 14 Dec 2001, Stas Bekman wrote:

just use this instead: 'use 5.8.0;'
which will run before ::load is called.

> Also what was the trick to avoid the bootstrap if tried outside of 
> modperl env?

the generated code spits out Apache::XSLoader::load for Apache classes and
APR::XSLoader::load for APR.  both of which take care of proper
bootstrapping inside and outside httpd.

'use APR ()' combined with APR::XSLoader::load will load APR/PerlIO.so
outside of httpd.  whereas Apache::XSLoader::load is a noop outside of
httpd.

> But since Apache::SubProcess could be used outside of mod_perl, this is 
> probably not good enough.

if that's the case, it should be APR::SubProcess.  it should only be named
Apache::SubProcess if it references ap_ symbols.

> The problem I have is that I need to add 
> APACHE_TEST_CONFIGURE in the subprocess.pm and blows up on require 
> outside mod_perl with a weird core:

looks like either a corrupt stack, dereferencing a NULL function pointer,
or function pointer called with prototype mismatch.

could also be because the current APR::PerlIO cannot be used outside of
httpd since it references modperl_global_get_pconf().
but i would expect an 'unable to resolve symbol' error from the linker,
not a wacky blowup like that.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Fri, 14 Dec 2001, Stas Bekman wrote:
> 
> 
>>I'm not satisfied with autogenerated 
>>WrapXS/Apache/SubProcess/SubProcess.pm, since I need to require 
>>APR::PerlIO in it, and I don't really want to create the SubProcess.xs 
>>and Makefile.PL in xs/Apache/SubProcess/. Do you think it's OK for 
>>WrapXS to check whether foo.pm already exists and not to generate it if 
>>so and use the existing one.
>>
> 
> try this:
> echo 'use APR::PerlIO ();' > xs/Apache/SubProcess/SubProcess_pm
> 
> the contents of SubProcess_pm will be included in the generated
> SubProcess.pm.


nice :) it's good enough for me to get going now.

What if the thing is trickier than just appending a line? I didn't 
resolve all the problems yet, but it seems that it *may* look like this:

package Apache::SubProcess;

our $VERSION = '0.01';
use Apache::XSLoader ();

if ($^V and $^V lt v5.7.2) {
     # XXX: make it 5.8.0 when it gets released
     warn "__PACKAGE__ can be used with perl 5.7.2 and onwards";
}
else {
     require APR::PerlIO;
}
    Apache::XSLoader::load __PACKAGE__;
1;

Also what was the trick to avoid the bootstrap if tried outside of 
modperl env?

     if ($ENV{MOD_PERL}) {
         __PACKAGE__->bootstrap($VERSION);
     }

But since Apache::SubProcess could be used outside of mod_perl, this is 
probably not good enough. The problem I have is that I need to add 
APACHE_TEST_CONFIGURE in the subprocess.pm and blows up on require 
outside mod_perl with a weird core:

warning: core file may not match specified executable file.
Core was generated by `/home/stas/perl/ithread/bin/perl 
/home/stas/apache.org/mp-subproc/t/TEST -confi'.
Program terminated with signal 11, Segmentation fault.
#0  0x403ccbea in ?? ()
(gdb) where
#0  0x403ccbea in ?? ()
#1  0x403bf6e2 in ?? ()
#2  0x403db99f in ?? ()
#3  0x403e2159 in ?? ()
#4  0x403e1acc in ?? ()
#5  0x400b7b10 in ?? ()
#6  0x400965f9 in ?? ()
#7  0x4003bf20 in ?? ()
#8  0x4003baa2 in ?? ()
#9  0x4004053b in ?? ()
#10 0x4004000e in ?? ()
#11 0x400798be in ?? ()
#12 0x40074471 in ?? ()
#13 0x4006850b in ?? ()
#14 0x400f7ac8 in ?? ()
#15 0x400f9b33 in ?? ()
#16 0x400965f9 in ?? ()
#17 0x4003aee6 in ?? ()
#18 0x4003a981 in ?? ()
#19 0x08049435 in ?? ()
#20 0x401ea6a0 in ?? ()

Everything is updated, but it still gives me this weird trace... :(

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: passing through an existing foo.pm from xs

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 14 Dec 2001, Stas Bekman wrote:

> I'm not satisfied with autogenerated 
> WrapXS/Apache/SubProcess/SubProcess.pm, since I need to require 
> APR::PerlIO in it, and I don't really want to create the SubProcess.xs 
> and Makefile.PL in xs/Apache/SubProcess/. Do you think it's OK for 
> WrapXS to check whether foo.pm already exists and not to generate it if 
> so and use the existing one.

try this:
echo 'use APR::PerlIO ();' > xs/Apache/SubProcess/SubProcess_pm

the contents of SubProcess_pm will be included in the generated
SubProcess.pm.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org