Archived
This forum has been archived. Please start a new discussion on GitHub.
IceInternal::incRef segmentation fault
xdm
La Coruña, Spain
in Help Center
Hello i have the next slice and c++ codes thats produce a segmentation fault in IceInternal::incRef i atach the stack trace of this crash, any ideas what is wrong
i using Ice-3.0.1 | gcc version 3.4.5 | AMD 64
thanks
i using Ice-3.0.1 | gcc version 3.4.5 | AMD 64
thanks
module Oz { module Web { /** * Este componente emcapsula el objeto Cookie del protocolo HTTP */ interface CookieAdmin { string getPath(); void setName(string name); string getName(); void setValue(string value); string getValue(); bool isSecure(); int getTimeOut(); }; class Cookie implements CookieAdmin { string name; string path; string value; int timeOut; bool secure; }; dictionary<string,Cookie>CookieMap; }; };
void WebAppHandler::writeCookies(const ResponsePtr& response,MaRequest* rq) { Oz::Web::CookieMap::iterator it; for(it=response->getCookies().begin(); it!=response->getCookies().end(); ++it) { CookiePtr cookie = (*it).second; char* name=(char*)malloc((cookie->getName().length()+1)*sizeof(char)); strcpy(name,cookie->getName().c_str()); char* value=(char*)malloc((cookie->getValue().length()+1)*sizeof(char)); strcpy(value,cookie->getValue().c_str()); char* path=(char*)malloc((cookie->getPath().length()+1)*sizeof(char)); strcpy(path,cookie->getPath().c_str()); rq->setCookie(name,value,cookie->getTimeOut(),path,cookie->isSecure()); delete name; delete value; delete path; cookie = 0; } }
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 46912538663520 (LWP 27906)] 0x0000000000000000 in ?? () (gdb) bt #0 0x0000000000000000 in ?? () #1 0x00002aaaae7aa14b in IceInternal::incRef (p=0x2aaaabc5e320) at Cookie.cpp:55 #2 0x00002aaaad88ba8d in Handle (this=0x7fffffbe25f0, r=@0x7fffffbe26b0) at Handle.h:83 #3 0x00002aaaad888f82 in WebAppHandler::writeCookies (this=0x593fd0, response=@0x7fffffbe2b60, rq=0x58fed0) at WebAppHandler.cpp:344 #4 0x00002aaaad887ffb in WebAppHandler::writeResponse (this=0x593fd0, response=@0x7fffffbe2b60, rq=0x58fed0) at WebAppHandler.cpp:290 #5 0x00002aaaad887e8e in WebAppHandler::run (this=0x593fd0, rq=0x58fed0) at WebAppHandler.cpp:272 #6 0x00002aaaaac0b8cb in MaRequest::runHandlers () from /opt/appweb/lib/libappWeb.so.1 #7 0x00002aaaaac070fd in MaRequest::processRequest () from /opt/appweb/lib/libappWeb.so.1 #8 0x00002aaaaac06ad0 in MaRequest::readEvent () from /opt/appweb/lib/libappWeb.so.1 #9 0x00002aaaaac0676c in MaRequest::acceptEvent () from /opt/appweb/lib/libappWeb.so.1 #10 0x00002aaaaac1580b in MprSocket::ioProc () from /opt/appweb/lib/libappWeb.so.1 #11 0x00002aaaaac156dc in MprSocket::getPort () from /opt/appweb/lib/libappWeb.so.1 #12 0x00002aaaaac0f9d6 in MprSelectService::serviceIO () from /opt/appweb/lib/libappWeb.so.1 #13 0x00002aaaaabff71c in Mpr::serviceIO () from /opt/appweb/lib/libappWeb.so.1 #14 0x00002aaaaabff454 in Mpr::serviceEvents () from /opt/appweb/lib/libappWeb.so.1 #15 0x0000000000400ff5 in Oz::Web::WebServer::run (this=0x7fffffbe3310, argc=1, argv=0x7fffffbe3428) at WebServer.cpp:56 #16 0x00000000004010b9 in main (argc=1, argv=0x7fffffbe3428) at main.cpp:9
0
Comments
-
Hi Jose,
Oz::Web::CookieMap::iterator it; for(it=response->getCookies().begin(); it!=response->getCookies().end(); ++it) { CookiePtr cookie = (*it).second;
What is the signature of getCookies()? If it returns a copy, then your iteration is not correct and you crash because you iterate too far in the first cookies collection.
Cheers,
Bernard0 -
getCookies returns a CookieMap , i now see whatś wrong
thanks0