Segmentation fault processing get over ssl

Hi,

I am using libwww within an apache module.  I am using it to submit a
http get request to a remote server, processes the response from the
remote server and notifies the user of results.

However, approximately every fourth request handled by this process
exits with a segmentation fault.

I am using the openssl 0.9.6c.  This problem first appeared with version
5.3.2 of libwww.  I proceeded to get the latest source as of yesterday
3/8 to see if it was addressed but the same problem occurred.

Thanks for your help.

Trace results and source code follow.

---- trace results ----

[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocess.c(30): getting
payment type
[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocess.c(32): demo
[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocess.c(34):
/sts-83-launch.mpeg
[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocess.c(36): 1.50
[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocess.c(38): 
[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocess.c(40): 
[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocess.c(75):
/liquify/payment-process/demo?rd=/sts-83-launch.mpeg&p=1.50&usr=&pwd=
[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocessor_demo.c(97):
initializing the htprofile
WWWLibInit.. INITIALIZING LIBRARY OF COMMON CODE
User Profile Adding `LIBWWW_GENERIC_USER'
User Profile Localizing 0x81595e0
HostName.... gethostname says `server1.liquify.biz'
HostName.... FQDN is `server1.liquify.biz'
MailAddress. getlogin returns NULL
HostName.... gethostname says `server1.liquify.biz'
HostName.... FQDN is `server1.liquify.biz'
Alert Call.. Add Alert Handler 0x408bd684
Alert Call.. Add Alert Handler 0x408bd98c
Alert Call.. Add Alert Handler 0x408bd6dc
Alert Call.. Add Alert Handler 0x408bd7ec
Alert Call.. Add Alert Handler 0x408bd8d0
Alert Call.. Add Alert Handler 0x408bd928
Transport... Adding `tcp'
Transport... Adding `buffered_tcp'
Transport... Adding `local'
Protocol.... Adding `ftp'
Protocol.... Adding `nntp'
Protocol.... Adding `news'
Protocol.... Adding `gopher'
Protocol.... Adding `http'
Protocol.... Adding `file'
Protocol.... Adding `cache'
Protocol.... Adding `telnet'
Protocol.... Adding `tn3270'
Protocol.... Adding `rlogin'
Net Before.. Add 0x408bf460 with order 49150 tmplate `http://*' context
(nil)
Net Before.. Add 0x408f436c with order 49150 tmplate `http://*' context
(nil)
Net Before.. Add 0x408beebc with order 49150 tmplate `<null>' context
(nil)
Net Before.. Add 0x408bedd0 with order 49150 tmplate `<null>' context
(nil)
Net After... Add 0x408bf4d0 with order 32767 tmplate `http://*' code
-401 context (nil)
Net After... Add 0x408bf4d0 with order 32767 tmplate `http://*' code
-418 context (nil)
Net After... Add 0x408f4418 with order 32767 tmplate `http://*' code 1
context (nil)
Net After... Add 0x408bf1a4 with order 32767 tmplate `http://*' code 301
context (nil)
Net After... Add 0x408bf1a4 with order 32767 tmplate `http://*' code 302
context (nil)
Net After... Add 0x408bf1a4 with order 32767 tmplate `http://*' code 303
context (nil)
Net After... Add 0x408bf1a4 with order 32767 tmplate `http://*' code 307
context (nil)
Net After... Add 0x408bf518 with order 32767 tmplate `http://*' code 1
context (nil)
Net After... Add 0x408bf34c with order 32767 tmplate `http://*' code 305
context (nil)
Net After... Add 0x408beffc with order 49150 tmplate `<null>' code 1
context (nil)
Proxy....... Looking for environment variables
Conversions. Adding 0x4094844c with quality 1.00
Conversions. Adding 0x408fcd2c with quality 1.00
Conversions. Adding 0x408fce90 with quality 1.00
Conversions. Adding 0x408fcdf4 with quality 1.00
Conversions. Adding 0x408fce28 with quality 1.00
Conversions. Adding 0x408fce5c with quality 1.00
Conversions. Adding 0x408fcfac with quality 1.00
Conversions. Adding 0x408fd18c with quality 1.00
Conversions. Adding 0x408fbcb4 with quality 1.00
Conversions. Adding 0x408d7c80 with quality 1.00
Conversions. Adding 0x408f0098 with quality 1.00
Conversions. Adding 0x408e345c with quality 1.00
Conversions. Adding 0x408e3504 with quality 1.00
Conversions. Adding 0x4089c628 with quality 1.00
Conversions. Adding 0x4089c628 with quality 1.00
Conversions. Adding 0x4090d2b4 with quality 1.00
Conversions. Adding 0x4092555c with quality 1.00
Conversions. Adding 0x40925570 with quality 1.00
Conversions. Adding 0x408c2ce4 with quality 1.00
Conversions. Adding 0x4094849c with quality 0.30
Codings..... Adding deflate with quality 1.00
Codings..... Adding chunked with quality 1.00
Codings..... Adding deflate with quality 1.00
Icon add.... BLANK => SRC="blank.xbm" ALT=""
Icon add.... DIRECTORY => SRC="directory.xbm" ALT="DIR"
Icon add.... PARENT => SRC="back.xbm" ALT="UP"
Icon add.... UNKNOWN => SRC="unknown.xbm" ALT=""
AddIcon..... */* => SRC="unknown.xbm" ALT=""
AddIcon..... binary => SRC="binary.xbm" ALT="BIN"
AddIcon..... www/unknown => SRC="unknown.xbm" ALT=""
AddIcon..... text/* => SRC="text.xbm" ALT="TXT"
AddIcon..... image/* => SRC="image.xbm" ALT="IMG"
AddIcon..... video/* => SRC="movie.xbm" ALT="MOV"
AddIcon..... audio/* => SRC="sound.xbm" ALT="AU"
AddIcon..... multipart/x-tar => SRC="tar.xbm" ALT="TAR"
AddIcon..... multipart/x-gtar => SRC="tar.xbm" ALT="TAR"
AddIcon..... x-compress => SRC="compressed.xbm" ALT="CMP"
AddIcon..... x-gzip => SRC="compressed.xbm" ALT="GZP"
AddIcon..... application/x-gopher-index => SRC="index.xbm" ALT="IDX"
AddIcon..... application/x-gopher-cso => SRC="index2.xbm" ALT="CSO"
AddIcon..... application/x-gopher-telnet => SRC="telnet.xbm" ALT="TEL"
AddIcon..... application/x-gopher-duplicate => SRC="unknown.xbm"
ALT="DUP"
AddIcon..... application/x-gopher-tn3270 => SRC="unknown.xbm" ALT="TN"
Event....... registering 0x408be458
Event....... registering 0x408be5bc
HTSSLContext Created context 0x8157d68Transport... Adding `secure_tcp'
Protocol.... Adding `https'
Net Before.. Add 0x408bf460 with order 49150 tmplate `https://*' context
(nil)
Net Before.. Add 0x408f436c with order 49150 tmplate `https://*' context
(nil)
Net After... Add 0x408bf4d0 with order 32767 tmplate `https://*' code
-401 context (nil)
Net After... Add 0x408bf4d0 with order 32767 tmplate `https://*' code
-418 context (nil)
Net After... Add 0x408f4418 with order 32767 tmplate `https://*' code 1
context (nil)
Net After... Add 0x408bf1a4 with order 32767 tmplate `https://*' code
301 context (nil)
Net After... Add 0x408bf1a4 with order 32767 tmplate `https://*' code
302 context (nil)
Net After... Add 0x408bf1a4 with order 32767 tmplate `https://*' code
303 context (nil)
Net After... Add 0x408bf1a4 with order 32767 tmplate `https://*' code
307 context (nil)
Net After... Add 0x408bf34c with order 32767 tmplate `https://*' code
305 context (nil)
Net After... Add 0x406e1984 with order 65535 tmplate `<null>' code 1
context 0x80c8260
[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocessor_demo.c(109):
setting timeout to 20 seconds
Host........ Setting event timeout to 60000 ms
[Sat Mar  9 11:03:33 2002] [debug] mod_liquify_payprocessor_demo.c(135):
creating the request
Request..... Created 0x81583f0
ChunkStream. Chunk 0x8158580 created with max size 0
HTAccess.... Accessing document
https://server2.liquify.biz:8443/forklift/servlet/forklift.paymentproces
sor.PaymentProcessorDemo?rd=/sts-83-launch.mpeg&p=1.50&usr=&pwd=&seller_
account=content_owner@liquify.biz
Net Before.. calling 0x408bf460 (request 0x81583f0, context (nil))
URL Tree.... did NOT find `w3c-AA'
Credentials. verified
Net Before.. calling 0x408beebc (request 0x81583f0, context (nil))
Net Before.. calling 0x408bf460 (request 0x81583f0, context (nil))
URL Tree.... did NOT find `w3c-AA'
Credentials. verified
Net Before.. calling 0x408beebc (request 0x81583f0, context (nil))
Net Before.. calling 0x408bf460 (request 0x81583f0, context (nil))
URL Tree.... did NOT find `w3c-AA'
Credentials. verified
Net Before.. calling 0x408beebc (request 0x81583f0, context (nil))
Net Before.. calling 0x408bedd0 (request 0x81583f0, context (nil))
Net Before.. calling 0x408f436c (request 0x81583f0, context (nil))
URL Tree.... did NOT find `w3c-pep'
Net Before.. calling 0x408bedd0 (request 0x81583f0, context (nil))
Net Before.. calling 0x408f436c (request 0x81583f0, context (nil))
URL Tree.... did NOT find `w3c-pep'
Net Before.. calling 0x408bedd0 (request 0x81583f0, context (nil))
Net Before.. calling 0x408f436c (request 0x81583f0, context (nil))
URL Tree.... did NOT find `w3c-pep'
Net Object.. 0x815d258 created with hash 2
Net Object.. starting request 0x81583f0 (retry=1) with net object
0x815d258
HTTP........ Looking for
`https://server2.liquify.biz:8443/forklift/servlet/forklift.paymentproce
ssor.PaymentProcessorDemo?rd=/sts-83-launch.mpeg&p=1.50&usr=&pwd=&seller
_account=content_owner@liquify.biz'
HTHost parse Looking up `server2.liquify.biz' on port 8443
Event....... Created event 0x815d510 with context 0x815d0e8, priority
20, and timeout 60000
Event....... Created event 0x815d528 with context 0x815d0e8, priority
20, and timeout 60000
Event....... Created event 0x815d540 with context 0x815d0e8, priority
20, and timeout 60000
Host info... added `server2.liquify.biz' with host 0x815d0e8 to list
0x815d4e8
Host connect Grabbing lock on Host 0x815d0e8 with 0x815d258
Host info... Added Net 0x815d258 (request 0x81583f0) to pipe on Host
0x815d0e8, 1 requests made, 1 requests in pipe, 0 pending
HTHost...... No ActivateRequest callback handler registered
HTHost 0x815d0e8 going to state TCP_CHANNEL.
HTHost 0x815d0e8 going to state TCP_DNS.
DNS Add..... `server2.liquify.biz' with 1 home(s) to 0x815d698
ParseInet... as port 8443 on 66.216.95.57 with 1 homes
HTHost 0x815d0e8 going to state TCP_NEED_SOCKET.
Socket...... Created 6
Net Manager. Increasing active sockets to 1, 2 persistent sockets
Socket...... Turned off Nagle's algorithm
Socket...... Blocking socket
Channel..... Hash value is 6
Channel..... Added 0x815d840 to list 0x815d830
HTSSLWriter. Created 0x8170800
Socket...... TCP send buffer size is 16384 for socket 6
HTHost 0x815d0e8 going to state TCP_NEED_CONNECT.
HTHost 0x815d0e8 going to state TCP_CONNECTED.
HTHost 0x815d0e8 connected.
Host connect Unlocking Host 0x815d0e8
HTTP........ Force flush on preemptive load
StreamStack. Constructing stream stack for text/x-http to */*
Host Event.. FLUSH passed to
`https://server2.liquify.biz:8443/forklift/servlet/forklift.paymentproce
ssor.PaymentProcessorDemo?rd=/sts-83-launch.mpeg&p=1.50&usr=&pwd=&seller
_account=content_owner@liquify.biz'
HTTP........ Generating HTTP/1.x Request Headers
HTTP........ Generating General Headers
Buffer...... Flushing 0x8170818
HTSSL New... Created new SSL Object 0x8174b18
HTSSL....... Setting up 0x8174b18 on socket 6
HTSSL....... New reference count = 1
SSL_connect: before/connect initialization
SSL_connect: SSLv2/v3 write client hello A
SSL_connect: SSLv3 read server hello A
depth = 0 /C=US/ST=Illinois/L=Chicago/O=SysreQ/OU=SysreQ/CN=Mark
Stanislawek
verify error: num=18:self signed certificate
verify return: 1
depth = 0 /C=US/ST=Illinois/L=Chicago/O=SysreQ/OU=SysreQ/CN=Mark
Stanislawek
verify return: 1
SSL_connect: SSLv3 read server certificate A
SSL_connect: SSLv3 read server done A
SSL_connect: SSLv3 write client key exchange A
SSL_connect: SSLv3 write change cipher spec A
SSL_connect: SSLv3 write finished A
SSL_connect: SSLv3 flush data
SSL_connect: SSLv3 read finished A
HTSSLWriter. SSL returned 0
HTSSLWriter. 315 bytes written to 6
HTSSL New... Found SSL 0x8174b18 with sd =  6
HTSSL....... New reference count = 2
HTSSLReader. SSL returned 0
HTSSLReader. 159 bytes read from socket 6
Response.... Created 0x815f5d8
Host info... New mode is 1 for host 0x815d0e8
Net Manager. 1 active sockets, increasing persistent sockets to 3
Host info... added host 0x815d0e8 as persistent
Net Object.. Persistent connection set ON succeeded
StreamStack. Constructing stream stack for message/rfc822 to */*
Error....... Add   2	Severity: 8	Parameter: `OK'	Where:
`HTTPNextState'
Host........ passing 17 bytes as consumed to 0x81687e0
Host........ 142 bytes remaining 
MIME header. Content-Type: text/html
MIME header. Content-Type: text/html
MIME header. Date: Sat, 09 Mar 2002 17:03:33 GMT
MIME header. Date: Sat, 09 Mar 2002 17:03:33 GMT
MIME header. Transfer-Encoding: chunked
MIME header. Transfer-Encoding: chunked
MIME header. Server: Apache Tomcat/4.0.3 (HTTP/1.1 Connector)
MIME header. Server: Apache Tomcat/4.0.3 (HTTP/1.1 Connector)
Building.... C-T stack from text/html to */*
StreamStack. Constructing stream stack for text/html to */*
StreamStack. Source output
Building.... Content-Decoding stack
Building.... Transfer-Decoding stack
C-E......... Looking for `chunked'
C-E......... Found...
Chunked..... Decoder stream created
Host........ passing 142 bytes as consumed to 0x81687e0
Host........ 0 bytes remaining 
HTSSLReader. SSL returned 0
HTSSLReader. 33 bytes read from socket 6
Chunked..... `15' chunk size: 15
Host........ passing 4 bytes as consumed to 0x81687e0
Host........ 29 bytes remaining 
Host........ passing 21 bytes as consumed to 0x81687e0
Host........ 8 bytes remaining 
Chunked..... `1' chunk size: 1
Host........ passing 5 bytes as consumed to 0x81687e0
Host........ 3 bytes remaining 
Host........ passing 1 bytes as consumed to 0x81687e0
Host........ 2 bytes remaining 
Host........ passing 2 bytes as consumed to 0x81687e0
Host........ 0 bytes remaining 
HTSSLReader. SSL returned 0
HTSSLReader. 5 bytes read from socket 6
Chunked..... `0' chunk size: 0
Host........ passing 3 bytes as consumed to 0x81687e0
Host........ 2 bytes remaining 
Host........ passing 2 bytes as consumed to 0x81687e0
Host........ 0 bytes remaining 
HTSSLReader. Target returns 200
HTTP Clean.. Called with status 200, net 0x815d258
Net Object.. Delete 0x815d258 and call AFTER filters
Host info... Remove 0x815d258 from pipe
Host Object. keeping persistent socket 6
Channel..... Delete 0x815d840 with semaphore 1, status 200
Channel..... Delete input stream 0x81687e0 from channel 0x815d840
HTSSLReader. Free 0x81687e0
HTSSL Free.. ref_count = 1
Chunked..... FREEING....
MIME........ FREEING....
Channel..... Delete input stream 0x81687e0 from channel 0x815d840
Channel..... Semaphore decreased to 0 for channel 0x815d840
Host........ Object 0x815d0e8 going idle...
Net Object.. Check for pending Net objects
Net Object.. Freeing object 0x815d258
Net After... calling 0x408f4418 (request 0x81583f0, response 0x815f5d8,
status 200, context (nil))
Net After... calling 0x408f4418 (request 0x81583f0, response 0x815f5d8,
status 200, context (nil))
Net After... calling 0x408f4418 (request 0x81583f0, response 0x815f5d8,
status 200, context (nil))
Net After... calling 0x408beffc (request 0x81583f0, response 0x815f5d8,
status 200, context (nil))
Load End.... OK:
`https://server2.liquify.biz:8443/forklift/servlet/forklift.paymentproce
ssor.PaymentProcessorDemo?rd=/sts-83-launch.mpeg&p=1.50&usr=&pwd=&seller
_account=content_owner@liquify.biz'
Net After... calling 0x408beffc (request 0x81583f0, response 0x815f5d8,
status 200, context (nil))
Load End.... OK:
`https://server2.liquify.biz:8443/forklift/servlet/forklift.paymentproce
ssor.PaymentProcessorDemo?rd=/sts-83-launch.mpeg&p=1.50&usr=&pwd=&seller
_account=content_owner@liquify.biz'
Net After... calling[Sat Mar  9 11:03:33 2002] [notice] child pid 31825
exit signal Segmentation fault (11)


---- source code ----


#include "httpd.h"
#include "http_config.h"
#include "http_protocol.h"
#include "ap_config.h"

#include "WWWLib.h"
#include "WWWHTTP.h"
#include "WWWInit.h"
#include "WWWSSL.h"

#include "liquify.h"
#include "liquify_util.h"

PRIVATE HTChunk *response = NULL;
PRIVATE request_rec *req_rec = NULL;

PRIVATE int tracer(const char *fmt, va_list pArgs)
{
    return (vfprintf(req_rec->server->error_log,fmt,pArgs));
    return 0;
}

PRIVATE int terminate_handler (HTRequest *request, HTResponse *response,
			 	void *param, int status)
{
	request_rec *r = (request_rec*)param;
	liquify_debug("before stoploop");
	HTEventList_stopLoop();
	liquify_debug("after stoploop");

	/* stop here */
	return HT_ERROR;
}

static int liquify_payprocessor_demo_handler(request_rec *r)
{
    int rc;
    const char *item, *price, *usr, *pwd;
    char *cookie;

    HTRequest *request = NULL;
    char *uri =
"https://server2.liquify.biz:8443/forklift/servlet/forklift.paymentproce
ssor.PaymentProcessorDemo";
    char *out_query_string = NULL;

    table *query_string = ap_make_table(r->pool,2);

    req_rec = r;

    if((rc = parse_query_str(r,&query_string)) != OK)
	return rc;

    item = ap_table_get(query_string,REQUESTED);
    price = ap_table_get(query_string,PRICE);
    usr = ap_table_get(query_string,USER_ID);
    pwd = ap_table_get(query_string,PASSWORD);

    /* Initialize libwww core */
    liquify_debug("initializing the htprofile");
    HTProfile_newNoCacheClient("Liquify","1.0");

    HTSSL_protMethod_set(HTSSL_V23);
    HTSSL_verifyDepth_set(2);
    HTSSLhttps_init(YES);

    HTTrace_setCallback(tracer);
    HTSetTraceMessageMask("sop");
 
HTNet_addAfter(terminate_handler,NULL,(void*)r,HT_ALL,HT_FILTER_LAST);

    /* Set the timeout for 20 seconds to wait for response */
    liquify_debug("setting timeout to 20 seconds");
    HTHost_setEventTimeout(60000);

    out_query_string = ap_pstrcat(r->pool,
			      "?",
			      REQUESTED,
			      "=",
			      item,
			      "&",
			      PRICE,
			      "=",
			      price,
			      "&",
			      USER_ID,
			      "=",
			      usr,
			      "&",
			      PASSWORD,
			      "=",
			      pwd,
			      "&",
			      "seller_account",
			      "="
			      "content_owner@liquify.biz",
			      NULL);

    liquify_debug("creating the request");
    request = HTRequest_new();
    HTRequest_setOutputFormat(request,WWW_SOURCE);
    HTRequest_addConnection(request,"close","");


    response =
HTLoadToChunk(ap_pstrcat(r->pool,uri,out_query_string,NULL),request);

    if(response)
    {

	HTEventList_newLoop();
        	
	/* processing response left out here for brevity */
    }
    else
    {
	r->content_type = "text/html";
    	ap_send_http_header(r);
	ap_rputs("We are sorry. ",r);
	ap_rputs("No Response was received from the payment processor.
",r);
       	ap_rputs("Please try your transaction again. ",r);
	rc = OK;
    }

    liquify_debug("deleting the response");
    HTChunk_delete(response);
    liquify_debug("deleting the request");
    HTRequest_delete(request);
    liquify_debug("terminate HTSSLhttps");
    HTSSLhttps_terminate();
    liquify_debug("deleting the profile");
    HTProfile_delete();
    liquify_debug("returning");
    return rc;

}

/* Dispatch list of content handlers */
static const handler_rec liquify_payprocessor_demo_handlers[] = {
    { "liquify-payprocessor-demo", liquify_payprocessor_demo_handler },
    { NULL, NULL }
};

/* Dispatch list for API hooks */
module MODULE_VAR_EXPORT liquify_payprocessor_demo_module = {
    STANDARD_MODULE_STUFF,
    NULL,                  /* module initializer                  */
    NULL,                  /* create per-dir    config structures */
    NULL,                  /* merge  per-dir    config structures */
    NULL,                  /* create per-server config structures */
    NULL,                  /* merge  per-server config structures */
    NULL,                  /* table of config file commands       */
    liquify_payprocessor_demo_handlers,       /* [#8]
MIME-typed-dispatched handlers */
    NULL,                  /* [#1] URI to filename translation    */
    NULL,                  /* [#4] validate user id from request  */
    NULL,                  /* [#5] check if the user is ok _here_ */
    NULL,                  /* [#3] check access by host address   */
    NULL,                  /* [#6] determine MIME type            */
    NULL,                  /* [#7] pre-run fixups                 */
    NULL,                  /* [#9] log a transaction              */
    NULL,                  /* [#2] header parser                  */
    NULL,                  /* child_init                          */
    NULL,                  /* child_exit                          */
    NULL                   /* [#0] post read-request              */
};

Received on Sunday, 10 March 2002 01:19:21 UTC