Re: [xml] another of those fun SEGV's in xmlFreeDoc?
- From: Rick Jones <rick jones2 hp com>
- To: veillard redhat com
- Cc: xml gnome org
- Subject: Re: [xml] another of those fun SEGV's in xmlFreeDoc?
- Date: Thu, 27 Oct 2005 09:14:15 -0700
At this point what would be next steps? Gentle, specific RTFM pointers
would be fine.
Are you moving parts of trees between documents ? If yes then you're
probably having dictionaries pointers problems. When loading documents with
xmlRead... use the XML_PARSE_NODICT option.
I don't _think_ I'm moving parts. There is a loop in handle_netperf_requests
that calls a routine pulling messages out of a socket when then get parsed and
processed:
static void
handle_netperf_requests()
{
int loc_debug = 0;
int rc = NPE_SUCCESS;
struct pollfd fds;
xmlDocPtr message;
...
rc = recv_control_message(netperf->sock, &message);
if (rc > 0) {
rc = process_message(netperf, message);
int32_t
recv_control_message(int control_sock, xmlDocPtr *message)
{
...receive a complete message off a socket...
/* now that we have the message, time to parse it. */
if ((*message = xmlParseMemory(message_base,message_len)) != NULL) {
if (debug) {
fprintf(where, "recv_control_message: xmlParseMemory returned %p\n",
*message);
fflush(where);
}
return(message_len);
} else {
...
}
int
process_message(server_t *server, xmlDocPtr doc)
{
int loc_debug = 0;
int rc = NPE_SUCCESS;
int cur_state = 0;
xmlChar *fromnid;
xmlNodePtr msg;
xmlNodePtr cur;
struct msgs *which_msg;
if (debug) {
fprintf(where,"process_message: entered\n");
fflush(where);
}
msg = xmlDocGetRootElement(doc);
if (msg == NULL) {
fprintf(stderr,"empty document\n");
fflush(stderr);
printf("freeing the %p empty doc\n",doc);
xmlFreeDoc(doc);
/* somehow I don't think that returning NPE_SUCCESS is the right
thing here? raj 2005-10-26 */
return(rc);
}
fromnid = xmlGetProp(msg,(const xmlChar *)"fromnid");
if (server != NULL) cur_state = 1 << server->state;
if (debug) {
fprintf(where,"process_message: received '%s' message from server %s\n",
msg->xmlChildrenNode->name, fromnid);
fprintf(where,"process_message: servers current state is %d\n", cur_state);
fflush(where);
}
for (cur = msg->xmlChildrenNode; cur != NULL; cur = cur->next) {
which_msg = np_msg_handler_base;
while (which_msg->msg_name != NULL) {
if (xmlStrcmp(cur->name,(xmlChar *)which_msg->msg_name)) {
which_msg++;
continue;
}
if (which_msg->valid_states & cur_state) {
rc = (which_msg->msg_func)(cur,doc,server);
if (rc != NPE_SUCCESS) {
fprintf(where,"process_message: received %d from %s\n",
rc, which_msg->msg_name);
fflush(where);
server->state = NSRV_ERROR;
if (server->sock != -1) {
close(server->sock);
/* should we delete the server from the server_hash ? sgb */
break;
}
}
} else {
if (debug || loc_debug) {
fprintf(where,
"process_message:state is %d got unexpected '%s' message.\n",
cur_state,
cur->name);
fflush(where);
}
}
which_msg++;
}
}
printf("freeing the %p doc doc\n",doc);
xmlFreeDoc(doc);
printf("freed the %p doc doc\n",doc);
return(rc);
}
What APIs do you use to build the document being freed is the main question.
The above.
rick
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]