Overview
Features
Download
Documentation
Community
Add-Ons & Services

glibc detected error (double free or corruption)

Please post support and help requests here.

glibc detected error (double free or corruption)

Postby jowa » 07 Sep 2012, 22:58

Hello forum,

I compiled and installed POCO 1.4.4 on CentOS 5.7. Compiler version is
gcc version 4.1.2 20080704 (Red Hat 4.1.2-52).

I was able to run the 'dict' example below in the samples folder. It printed out
messages retrieved from the remote site and passed debugging point1 and point2
near the end of the program.

However, when the program is done, it gives the following error which implies memory
corruption and pointer issues:

Any ideas why this happened?

Thank you.

-------------------------------------------------------------------------------------------------------------
//Listing 1

#include "Poco/Net/StreamSocket.h"
#include "Poco/Net/SocketStream.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/StreamCopier.h"
#include "Poco/Path.h"
#include "Poco/Exception.h"
#include <iostream>

using Poco::Net::StreamSocket;
using Poco::Net::SocketStream;
using Poco::Net::SocketAddress;
using Poco::StreamCopier;
using Poco::Path;
using Poco::Exception;

int main(int argc, char** argv)
{
const std::string HOST("dict.org");
const unsigned short PORT = 2628;

if (argc != 2)
{
Path p(argv[0]);
std::cout << "usage: " << p.getBaseName() << " <term>" << std::endl;
std::cout << " looks up <term> in dict.org and prints the results" << std::endl;
return 1;
}
std::string term(argv[1]);

try
{
SocketAddress sa(HOST, PORT);
StreamSocket sock(sa);
SocketStream str(sock);

str << "DEFINE ! " << term << "\r\n" << std::flush;

str << "QUIT\r\n" << std::flush;

sock.shutdownSend();

StreamCopier::copyStream(str, std::cout);

std::cout << "Point 1" << std::endl;

//return 0;
}
catch (Exception& exc)
{
std::cerr << exc.displayText() << std::endl;
return 1;
}

std::cout << "Point 2" << std::endl;
return 0;
}

--------------------------------------------------------------------------------------------------------------------------
//Listing 2

... ...
250 ok [d/m/c = 1/0/17; 0.000r 0.000u 0.000s]
221 bye [d/m/c = 0/0/0; 0.000r 0.000u 0.000s]
Point 1
Point 2
*** glibc detected *** ./mypoco: double free or corruption (!prev): 0x000000000c44ca60 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3a28e711df]
/lib64/libc.so.6(cfree+0x4b)[0x3a28e7163b]
/usr/lib64/libstdc++.so.6(_ZNSsD1Ev+0x3a)[0x3a3b49dbca]
/usr/local/lib/libPocoNetd.so.14[0x2af2e4237edc]
/lib64/libc.so.6(__cxa_finalize+0x8e)[0x3a28e337fe]
/usr/local/lib/libPocoNetd.so.14[0x2af2e4236296]
======= Memory map: ========
00400000-00402000 r-xp 00000000 fd:00 7394379 /root/playground/Debug/mypoco
00602000-00603000 rw-p 00002000 fd:00 7394379 /root/playground/Debug/mypoco
0c418000-0c45a000 rw-p 0c418000 00:00 0 [heap]
3a28a00000-3a28a1c000 r-xp 00000000 fd:00 6508170 /lib64/ld-2.5.so
3a28c1c000-3a28c1d000 r--p 0001c000 fd:00 6508170 /lib64/ld-2.5.so
3a28c1d000-3a28c1e000 rw-p 0001d000 fd:00 6508170 /lib64/ld-2.5.so
3a28e00000-3a28f4e000 r-xp 00000000 fd:00 6508282 /lib64/libc-2.5.so
3a28f4e000-3a2914d000 ---p 0014e000 fd:00 6508282 /lib64/libc-2.5.so
3a2914d000-3a29151000 r--p 0014d000 fd:00 6508282 /lib64/libc-2.5.so
3a29151000-3a29152000 rw-p 00151000 fd:00 6508282 /lib64/libc-2.5.so
3a29152000-3a29157000 rw-p 3a29152000 00:00 0
3a29200000-3a29282000 r-xp 00000000 fd:00 6508283 /lib64/libm-2.5.so
3a29282000-3a29481000 ---p 00082000 fd:00 6508283 /lib64/libm-2.5.so
3a29481000-3a29482000 r--p 00081000 fd:00 6508283 /lib64/libm-2.5.so
3a29482000-3a29483000 rw-p 00082000 fd:00 6508283 /lib64/libm-2.5.so
3a29600000-3a29602000 r-xp 00000000 fd:00 6508157 /lib64/libdl-2.5.so
3a29602000-3a29802000 ---p 00002000 fd:00 6508157 /lib64/libdl-2.5.so
3a29802000-3a29803000 r--p 00002000 fd:00 6508157 /lib64/libdl-2.5.so
3a29803000-3a29804000 rw-p 00003000 fd:00 6508157 /lib64/libdl-2.5.so
3a29a00000-3a29a16000 r-xp 00000000 fd:00 6508291 /lib64/libpthread-2.5.so
3a29a16000-3a29c15000 ---p 00016000 fd:00 6508291 /lib64/libpthread-2.5.so
3a29c15000-3a29c16000 r--p 00015000 fd:00 6508291 /lib64/libpthread-2.5.so
3a29c16000-3a29c17000 rw-p 00016000 fd:00 6508291 /lib64/libpthread-2.5.so
3a29c17000-3a29c1b000 rw-p 3a29c17000 00:00 0
3a2a200000-3a2a207000 r-xp 00000000 fd:00 6508302 /lib64/librt-2.5.so
3a2a207000-3a2a407000 ---p 00007000 fd:00 6508302 /lib64/librt-2.5.so
3a2a407000-3a2a408000 r--p 00007000 fd:00 6508302 /lib64/librt-2.5.so
3a2a408000-3a2a409000 rw-p 00008000 fd:00 6508302 /lib64/librt-2.5.so
3a32000000-3a32011000 r-xp 00000000 fd:00 6508304 /lib64/libresolv-2.5.so
3a32011000-3a32211000 ---p 00011000 fd:00 6508304 /lib64/libresolv-2.5.so
3a32211000-3a32212000 r--p 00011000 fd:00 6508304 /lib64/libresolv-2.5.so
3a32212000-3a3Aborted

--------------------------------------------------------------------------------------------------------------------------
jowa
 
Posts: 6
Joined: 07 Sep 2012, 22:44

Re: glibc detected error (double free or corruption)

Postby jowa » 10 Sep 2012, 19:28

It looks to me like a memory violate in Poco1.4.4. Suggestions anyone?
Have been stuck with this issue for a day and it's extremely frustrating
jowa
 
Posts: 6
Joined: 07 Sep 2012, 22:44

Re: glibc detected error (double free or corruption)

Postby guenter » 10 Sep 2012, 20:51

I cannot reproduce this behavior. Tested with CentOS 5.8 (gcc (GCC) 4.1.2 20080704) x86_64 and everything works fine. Also works fine on other platforms (OS X, Ubuntu).
guenter
 
Posts: 1112
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: glibc detected error (double free or corruption)

Postby jowa » 10 Sep 2012, 21:06

It looks that the above issue only happens consistently with a client when it exits, and does not
happen the server which runs continuously. I observed similar errors with the chat client
obtained from: http://www.alepho.com/index.php?do=coding&date=20110705

If you do a Google search on "terminate called after throwing instance poco systemexception",
similar issue reports will turn out, and I have not yet found a clear resolution from those posts.

Also this post (viewtopic.php?f=12&t=1308&p=2793#p2793)
suggested it is due to the way ErrorHandler works in Poco.

I am really surprised to get hit with this time hole upon playing with Poco, :(
jowa
 
Posts: 6
Joined: 07 Sep 2012, 22:44

Re: glibc detected error (double free or corruption)

Postby jowa » 10 Sep 2012, 21:19

Sorry about multiple posts. But if I do a while(true) {} in either the dictionary client or the chat client to force it not to exit,
the client will hang there after finishing the socket job without giving that error. At least this way I can kill the client with a control-C
without getting that error to proceed with my prototyping...

Thanks for your time.
jowa
 
Posts: 6
Joined: 07 Sep 2012, 22:44

Re: glibc detected error (double free or corruption)

Postby alex » 11 Sep 2012, 00:46

FWIW, I was NOT able to reproduce this behavior, either:
Code: Select all
$ uname -a
Linux ubuntu 3.0.0-19-generic #33-Ubuntu SMP Thu Apr 19 19:05:14 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
$ g++ --version
g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
alex
 
Posts: 1105
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: glibc detected error (double free or corruption)

Postby jowa » 11 Sep 2012, 19:58

My bad. I have two versions of the same lib in the link path,
e.g., libPocoFoundationd.so and libPocoFoundation.so.
Supposedly the one with a 'd' is the debug or development version
and the other is release version.

Thanks for your time.
jowa
 
Posts: 6
Joined: 07 Sep 2012, 22:44


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest