You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Da...@barclayscapital.com on 2009/03/26 15:54:23 UTC

APR_POLLSET_THREADSAFE crash on Cygwin


Hi,

I've got Cygwin's libapr1 1.3.3-1

I've built Ganglia (3.1.0) from source and it works.

I then modify this line of code in gmond.c, adding the flag
APR_POLLSET_THREADSAFE:

  apr_pollset_create(&listen_channels, total_listen_channels,
global_context, APR_POLLSET_THREADSAFE);

Now, after adding a socket to the pollset, there is a segmentation
fault.  gdb is unable to show me a backtrace.

On Linux and Solaris, with apr 1.2.7, there is no fault, it only happens
under Cygwin which ships with apr 1.3.3.

I'm going to try compiling 1.2.7 under Cygwin, but can anyone make any
suggestions about the fault?

Regards,

Daniel
_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
_______________________________________________

RE: APR_POLLSET_THREADSAFE crash on Cygwin

Posted by Da...@barclayscapital.com.
 
> > 
> > Did apr-1.2.x even know about APR_POLLSET_THREADSAFE?
> > 
> 
> I've just been referring to the online API docs, I didn't see version
> information for this feature.
> 
> However, it definitely makes a differences if it is enabled 
> or not.  If
> I don't have this option, then gmond dies with SIGPIPE, usually at the
> time when it receives an incoming TCP connection and starts 
> writing the
> response.
>


I finally have some more detail about what is wrong, a number of issues
exist:

 - the apr package in Cygwin doesn't appear to be compiled with thread
support

 - when I compiled my own apr 1.2.7 package, even with --enable-threads,
it still didn't compile with threads (but there was no obvious warning
from configure), I had to manually edit configure.in and comment out the
line enabled_threads=no in the cygwin code:

--- configure.in        (revision 197)
+++ configure.in        (working copy)
@@ -407,7 +407,7 @@
    *cygwin*)
        OSDIR="unix"
        APR_ADDTO(CPPFLAGS,-DCYGWIN)
-       enable_threads="no"
+       #enable_threads="no"
        eolstr="\\n"
        ;;
    *hpux10* ) 

 - on Cygwin, with or without apr compiled for thread support, calling
apr_pollset_create with APR_POLLSET_THREADSAFE still returns
APR_SUCCESS, however, the seg fault occurs consistently on subsequent
functions

_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
_______________________________________________

RE: APR_POLLSET_THREADSAFE crash on Cygwin

Posted by Da...@barclayscapital.com.
> 	I've now added this check, and apr_pollset_create is returning
> 	APR_SUCCESS
> 	
> 	The seg fault only occurs after the first socket is added to the
> 	pollset, maybe there is another place where return 
> codes are ignored?
> 
> 
> Hmmm...  I see that poll() or select()-based pollset 
> implementations return APR_ENOTIMPL when 
> APR_POLLSET_THREADSAFE is spectified, and I don't know how 
> Windows could use anything else under the covers ;)
> 

This is the revised code, I now get my segfault on the
err_msg("apr_pollset_create success"):

  /* Create my incoming pollset */
  status = apr_pollset_create(&listen_channels, total_listen_channels,
global_context, APR_POLLSET_THREADSAFE);
  if(status != APR_SUCCESS)
    {
      err_msg("apr_pollset_create failed: %s");
      exit(1);
    }
  err_msg("apr_pollset_create success");
> 	my modules start threads.  One of them, which works on Linux and
> 	Solaris, uses libcurl from another thread, and I was 
> getting crashes
> 	until I added APR_POLLSET_THREADSAFE.  Now I want to 
> run the same code
> 	under Cygwin.
> 
> 
> Weird...  I would expect that APR_POLLSET_THREADSAFE is only 
> needed with use of the SAME pollset on multiple threads, and 
> using libcurl from another thread wouldn't affect Ganglia's 
> use of its own pollset.
> 
> Sorry!
>  
> 
> 	I have tested this with apr-1.2.7 under Cygwin now, it 
> also has the same
> 	issue.
> 
> 
> Did apr-1.2.x even know about APR_POLLSET_THREADSAFE?
> 

I've just been referring to the online API docs, I didn't see version
information for this feature.

However, it definitely makes a differences if it is enabled or not.  If
I don't have this option, then gmond dies with SIGPIPE, usually at the
time when it receives an incoming TCP connection and starts writing the
response.

_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
_______________________________________________

Re: APR_POLLSET_THREADSAFE crash on Cygwin

Posted by Jeff Trawick <tr...@gmail.com>.
On Thu, Mar 26, 2009 at 8:24 PM, <Da...@barclayscapital.com> wrote:

>
> > APR_POLLSET_THREADSAFE isn't supported with all
> > implementations.  I expect that apr_pollset_create() is
> > returning APR_ENOTIMPL, and the crash is due to an
> > uninitialized pollset.
>
> Excellent point - I should have checked for a return code, there are a
> few cases like this in Ganglia where the return codes are ignored.
>
> I've now added this check, and apr_pollset_create is returning
> APR_SUCCESS
>
> The seg fault only occurs after the first socket is added to the
> pollset, maybe there is another place where return codes are ignored?


Hmmm...  I see that poll() or select()-based pollset implementations return
APR_ENOTIMPL when APR_POLLSET_THREADSAFE is spectified, and I don't know how
Windows could use anything else under the covers ;)



>
> >
> > Just curious: Does Ganglia modify the pollset on a separate
> > thread than the poll (thus needing APR_POLLSET_THREADSAFE),
> > and if so why doesn't it already specify
> > APR_POLLSET_THREADSAFE *and* check the apr_pollset_create()
> > return code?  And if it doesn't need it, what do you expect
> > to gain by adding it?
>
> Ganglia doesn't need it normally, it is just a single thread.  The seg
> fault occurs during the single threaded initialisation phase where
> sockets are created.
>
> However, I am taking advantage of Ganglia's new module API, and some of
> my modules start threads.  One of them, which works on Linux and
> Solaris, uses libcurl from another thread, and I was getting crashes
> until I added APR_POLLSET_THREADSAFE.  Now I want to run the same code
> under Cygwin.


Weird...  I would expect that APR_POLLSET_THREADSAFE is only needed with use
of the SAME pollset on multiple threads, and using libcurl from another
thread wouldn't affect Ganglia's use of its own pollset.

Sorry!


> I have tested this with apr-1.2.7 under Cygwin now, it also has the same
> issue.


Did apr-1.2.x even know about APR_POLLSET_THREADSAFE?

RE: APR_POLLSET_THREADSAFE crash on Cygwin

Posted by Da...@barclayscapital.com.
> APR_POLLSET_THREADSAFE isn't supported with all 
> implementations.  I expect that apr_pollset_create() is 
> returning APR_ENOTIMPL, and the crash is due to an 
> uninitialized pollset.

Excellent point - I should have checked for a return code, there are a
few cases like this in Ganglia where the return codes are ignored.

I've now added this check, and apr_pollset_create is returning
APR_SUCCESS

The seg fault only occurs after the first socket is added to the
pollset, maybe there is another place where return codes are ignored?

> 
> Just curious: Does Ganglia modify the pollset on a separate 
> thread than the poll (thus needing APR_POLLSET_THREADSAFE), 
> and if so why doesn't it already specify 
> APR_POLLSET_THREADSAFE *and* check the apr_pollset_create() 
> return code?  And if it doesn't need it, what do you expect 
> to gain by adding it?

Ganglia doesn't need it normally, it is just a single thread.  The seg
fault occurs during the single threaded initialisation phase where
sockets are created.

However, I am taking advantage of Ganglia's new module API, and some of
my modules start threads.  One of them, which works on Linux and
Solaris, uses libcurl from another thread, and I was getting crashes
until I added APR_POLLSET_THREADSAFE.  Now I want to run the same code
under Cygwin.

I have tested this with apr-1.2.7 under Cygwin now, it also has the same
issue.
_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
_______________________________________________

Re: APR_POLLSET_THREADSAFE crash on Cygwin

Posted by Jeff Trawick <tr...@gmail.com>.
On Thu, Mar 26, 2009 at 3:54 PM, <Da...@barclayscapital.com> wrote:

I've got Cygwin's libapr1 1.3.3-1
>
> I've built Ganglia (3.1.0) from source and it works.
>
> I then modify this line of code in gmond.c, adding the flag
> APR_POLLSET_THREADSAFE:
>
>  apr_pollset_create(&listen_channels, total_listen_channels,
> global_context, APR_POLLSET_THREADSAFE);
>
> Now, after adding a socket to the pollset, there is a segmentation
> fault.  gdb is unable to show me a backtrace.


APR_POLLSET_THREADSAFE isn't supported with all implementations.  I expect
that apr_pollset_create() is returning APR_ENOTIMPL, and the crash is due to
an uninitialized pollset.

Just curious: Does Ganglia modify the pollset on a separate thread than the
poll (thus needing APR_POLLSET_THREADSAFE), and if so why doesn't it already
specify APR_POLLSET_THREADSAFE *and* check the apr_pollset_create() return
code?  And if it doesn't need it, what do you expect to gain by adding it?