Overview
Features
Download
Documentation
Community
Add-Ons & Services

HTTPServer error on delete

Please post support and help requests here.

HTTPServer error on delete

Postby Hellbard » 03 Aug 2007, 09:33

Hi, I still have the same problem that I mentioned two month ago.

I use the HttpServer class to handle some HTTP requests and it works
perfect but when I try to destroy this object the application crashes. I do
not know why. Here is my code. Instead of double colon I will use double
semi-colon.

// for this method I start new thread
void provideServer (string http){
// create new RequestHandlerFactory
requestHandlerFactory = new RequestHandlerFactory();

// setting up the server
Poco;;Net;;HTTPServer* sr;
// set-up a server socket
try {
Poco;;Net;;SocketAddress sadr(http);
Poco;;Net;;ServerSocket svs(sadr);
sr = new Poco;;Net;;HTTPServer(requestHandlerFactory, svs, new
Poco;;Net;;HTTPServerParams);
} catch (Poco;;Exception e){
// manage errors
return;
}
// start HTTPServer
sr->start();

// log some message
LOG("server is running")

// releasing server
sr->stop();
delete sr;
delete requestHandlerFactory;

LOG("server stopped")
}

I work under MSVC 2005 express edition. Poco library was compiled on the
full version of Visual Studio 2005. However, the same problem occurs with
MSVC 2003 too.

When I try to delete the HttpServer it throws an assertion:

Debug assertion failed!
File: dbgdel.cpp
line: 52 // this is file from microsoft SDK
Expressin: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

When I try to continue it writes that this may be probably due to
a heap corruption and then throws the following error:

HEAP CORRUPTION DETECTED: before (null) block (#-1163005939) at
0x03372CB0. CRT detected that the application wrote to memory before start
of heap buffer

stack ends with this line
PocoNetd.dll!Poco;;Net;;HTTPServer;;`vector deleting destructor'() + 0x7a
bytes C++

Any ideas are welcome. Thanks for your advice.

Milan
Hellbard
 
Posts: 12
Joined: 16 Mar 2007, 11:21

Re: HTTPServer error on delete

Postby peter » 03 Aug 2007, 12:06

Well, looking at your code, I see only one error:
The HTTPServer docu states that the server takes ownership of all pointers
passed to it including the requesthandlerfactory.
So the delete requestHandlerFactory; is definitely wrong.
I suggest to create the server like that:

sr = new Poco;;Net;;HTTPServer(new RequestHandlerFactory(), svs, new Poco;;Net;;HTTPServerParams);

so you no longer have the chance to delete the factory :-)

Still, it looks as if you don't even get that far. Go to
poco/Net/samples/HTTPTimeServer and try to compile and execute that one.
If this works, take that sample and simply exchange the RequestHandlerFactory
there with your own one (maybe it crashes inside the RequesthandlerFactory
destructor if you are deleting anything else there?).
If it doesn't work, then your build might be corrupt.
Rebuild and look for old poco installations/incorrect PATH
settings which cause your application to link the wrong libs.

br

Peter

> Hi, I still have the same problem that I mentioned two month ago.
>
> I use the HttpServer class to handle some HTTP requests and it works
> perfect but when I try to destroy this object the application crashes. I do
> not know why. Here is my code. Instead of double colon I will use double
> semi-colon.
>
> // for this method I start new thread
> void provideServer (string http){
> // create new RequestHandlerFactory
> requestHandlerFactory = new RequestHandlerFactory();
>
> // setting up the server
> Poco;;Net;;HTTPServer* sr;
> // set-up a server socket
> try {
> Poco;;Net;;SocketAddress sadr(http);
> Poco;;Net;;ServerSocket svs(sadr);
> sr = new Poco;;Net;;HTTPServer(requestHandlerFactory, svs, new
> Poco;;Net;;HTTPServerParams);
> } catch (Poco;;Exception e){
> // manage errors
> return;
> }
> // start HTTPServer
> sr->start();
>
> // log some message
> LOG("server is running")
>
> // releasing server
> sr->stop();
> delete sr;
> delete requestHandlerFactory;
>
> LOG("server stopped")
> }
>
> I work under MSVC 2005 express edition. Poco library was compiled on the
> full version of Visual Studio 2005. However, the same problem occurs with
> MSVC 2003 too.
>
> When I try to delete the HttpServer it throws an assertion:
>
> Debug assertion failed!
> File: dbgdel.cpp
> line: 52 // this is file from microsoft SDK
> Expressin: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
>
> When I try to continue it writes that this may be probably due to
> a heap corruption and then throws the following error:
>
> HEAP CORRUPTION DETECTED: before (null) block (#-1163005939) at
> 0x03372CB0. CRT detected that the application wrote to memory before start
> of heap buffer
>
> stack ends with this line
> PocoNetd.dll!Poco;;Net;;HTTPServer;;`vector deleting destructor'() + 0x7a
> bytes C++
>
> Any ideas are welcome. Thanks for your advice.
>
> Milan
peter
 
Posts: 67
Joined: 11 Jul 2006, 16:26
Location: Austria

Re: HTTPServer error on delete

Postby Hellbard » 07 Aug 2007, 11:10

Thanks for response I tested what you have said.

It seems that error is not in poco but in some of my component that I use to manage memory.
Hellbard
 
Posts: 12
Joined: 16 Mar 2007, 11:21

Re: HTTPServer error on delete

Postby Hellbard » 17 Aug 2007, 07:16

Hi

I have one more question. I have still the same error. While I am trying to delete HttpServer it throws me Exception in "_BLOCK_TYPE_IS_VALID(pHeap->nBlockUse)". But it is only in debug version. When I compiled release version, all problems gone.
I have read on some forums, that this fault is probably by using mixed libraries. So I want to aks, if I compiled poco libraries right.

I need poco with ssl, so I take version poco-1.3.1-ssl. I use OpenSSL precompiled libraries by Shining Light Productions (http://www.slproweb.com/products/Win32OpenSSL.html).
I am working on msvc_2005.

I have compiled poco as debug-shared. DLLs were right but while compiling linker want more Poco .lib files like (PocoFoundationmtd, PocoNetmtd, ...) so I compiled poco as debug-static too.

Is this right?

With this libraries (Poco...d.lib and Poco...mtd.lib) I have not problems to compile my project. (I run this projct with Poco...d.dll.) .But when I try to delete some poco structures (only that ones that was created by me and released by me or by Poco) - like Context that is need for HTTPS server.

Do you see any substandard steps I have been doing while compilation or runnig poco application??

Thanks for any advice.
Hellbard
 
Posts: 12
Joined: 16 Mar 2007, 11:21


Return to Support

Who is online

Users browsing this forum: No registered users and 20 guests