You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by an...@uk.bnpparibas.com on 2010/06/16 11:08:41 UTC

help needed: heap corruption when activemq-cpp routines called

I have been seeing an intermittent heap corruption in my AMQ-cpp program, 
on and of, for some time now. It happens right at the start when it calls 
activemq::library::ActiveMQCPP::initializeLibrary(). Unfortunately, that 
which was intermittent is now happening every time.

I am using AMQ-cpp 3.1.0 in Windows-XP SP3, with VS 2005 (aka vc8).

By moving this call to at the very start of main, the bug relocates -- it 
then fails on this line of code:

 std::auto_ptr<activemq::core::ActiveMQConnectionFactory> 
connectionFactory(
        new activemq::core::ActiveMQConnectionFactory(queueManagerName));

The variable 'queueManagerName' is initialised correctly, it is set 
to"tcp://127.0.0.1:61616".

Output from VS is not very helpful:

First-chance exception at 0x7c919084 in myprog.exe: 0xC0000005: Access 
violation reading location 0x0000000f.
First-chance exception at 0x7c812afb in myprog.exe: Microsoft C++ 
exception: std::bad_alloc at memory location 0x0012ee7c..
HEAP[myprog.exe]: Heap block at 0541A820 modified at 0541A864 past 
requested size of 3c

I have tried using DUMA, a memory debugger, to shed any light but 
unfortunately, it yields nothing. Sadly, I do not have access to purify. 
Also the code is non-portable (don't ask) so I can't build it on linux and 
use valgrind.

The call stack looks like this:

        ntdll.dll!7c90120e() 
        [Frames below may be incorrect and/or missing, no symbols loaded 
for ntdll.dll] 
        ntdll.dll!7c96e139() 
        ntdll.dll!7c95f38c() 
        ntdll.dll!7c96e507() 
        ntdll.dll!7c9622e8() 
        ntdll.dll!7c90327a() 
        kernel32.dll!7c85f9a7() 
>       msvcr80d.dll!_CrtIsValidHeapPointer(const void * 
pUserData=0x0541a848)  Line 2072        C++
        msvcr80d.dll!_free_dbg_nolock(void * pUserData=0x0541a848, int 
nBlockUse=1)  Line 1279 + 0x9 bytes     C++
        msvcr80d.dll!_free_dbg(void * pUserData=0x0541a848, int 
nBlockUse=1)  Line 1220 + 0xd bytes     C++
        msvcr80d.dll!operator delete(void * pUserData=0x0541a848)  Line 54 
+ 0x10 bytes    C++
        myprog.exe!xms::ConnectionFactory::setProperty()  + 0x78e bytes 
C++
        myprog.exe!main(int argc=11, char * * argv=0x054172b0)  Line 457 + 
0x10 bytes      C++
        myprog.exe!__tmainCRTStartup()  Line 597 + 0x19 bytes   C
        myprog.exe!mainCRTStartup()  Line 414   C
        kernel32.dll!7c817077() 

This is weird because I do not call ConnectionFactory::setProperty(), and 
the only call I make to AMQ-cpp from main is the init call.

The problem does not occur in Release mode. Unfortunately I need Debug 
mode (for various reasons).

Recently a bug was reported in AMQ-cpp to do with deadlocks that bites 
Windows users. I am on the version that has that bug but I do not think 
that bug is responsible for this.

I am desperately in need of some help/guidance please.

Regards,

Andrew Marlow

___________________________________________________________
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is prohibited.

Please refer to http://www.bnpparibas.co.uk/en/information/legal_information.asp?Code=ECAS-845C5H  for additional disclosures.

Re: help needed: heap corruption when activemq-cpp routines called

Posted by Ivan Pechorin <iv...@gmail.com>.
2011/6/9 Ken Moore <km...@mooresweb.com>:
>>
>> Yes, that was definiately part of the problem. Also I had not used the
>> correct macros for checked iterators in the STL, to be consistent with the
>> rest of our build. It is all working now. Many thanks for your help
>>
> Can you tell me what macros you corrected to solve your problem? I am having
> the same issues here. I have the correct versions linked but am still getting
> the heap corruptions. Any help would be greatly appreciated.

I suppose, the macros in question is _SECURE_SCL. It is defined to 1
by default in two places within activemq-cpp:
src\main\activemq\util\Config.h and src\main\decaf\util\Config.h,
without any check if for release or debug mode. AFAIK, this behaviour
matches the defaults set in Visual Studio 2005 and 2008 (where
_SECURE_SCL defaults to 1 both in release and debug modes). Visual
Studio 2010 changed the default for release mode: _SECURE_SCL = 0.

Re: help needed: heap corruption when activemq-cpp routines called

Posted by Ken Moore <km...@mooresweb.com>.
Andrew Marlow <ma...@...> writes:

> 
> Yes, that was definiately part of the problem. Also I had not used the
> correct macros for checked iterators in the STL, to be consistent with the
> rest of our build. It is all working now. Many thanks for your help 
> 
> On Wed, Jul 14, 2010 at 3:35 AM, jolly.Wang <wa...@...> wrote:
> 
> >



Hi,

Can you tell me what macros you corrected to solve your problem? I am having 
the same issues here. I have the correct versions linked but am still getting 
the heap corruptions. Any help would be greatly appreciated.

Thanks,
Ken




Re: help needed: heap corruption when activemq-cpp routines called

Posted by Andrew Marlow <ma...@googlemail.com>.
Yes, that was definiately part of the problem. Also I had not used the
correct macros for checked iterators in the STL, to be consistent with the
rest of our build. It is all working now. Many thanks for your help :-)

On Wed, Jul 14, 2010 at 3:35 AM, jolly.Wang <wa...@163.com> wrote:

>
> I have the same problem. Here is the solution:
> when in debug mode, use activemq-cppd.lib(don't use activemq-cpp.lib:
> crash);when in release mode, use activemq-cpp.lib(don't use
> activemq-cppd.lib)。
>
>
>
> andrew.marlow wrote:
> >
> > I have been seeing an intermittent heap corruption in my AMQ-cpp program,
> > on and of, for some time now. It happens right at the start when it calls
> > activemq::library::ActiveMQCPP::initializeLibrary(). Unfortunately, that
> > which was intermittent is now happening every time.
> >
> > I am using AMQ-cpp 3.1.0 in Windows-XP SP3, with VS 2005 (aka vc8).
> >
> > By moving this call to at the very start of main, the bug relocates -- it
> > then fails on this line of code:
> >
> >  std::auto_ptr<activemq::core::ActiveMQConnectionFactory>
> > connectionFactory(
> >         new activemq::core::ActiveMQConnectionFactory(queueManagerName));
> >
> > The variable 'queueManagerName' is initialised correctly, it is set
> > to"tcp://127.0.0.1:61616".
> >
> > Output from VS is not very helpful:
> >
> > First-chance exception at 0x7c919084 in myprog.exe: 0xC0000005: Access
> > violation reading location 0x0000000f.
> > First-chance exception at 0x7c812afb in myprog.exe: Microsoft C++
> > exception: std::bad_alloc at memory location 0x0012ee7c..
> > HEAP[myprog.exe]: Heap block at 0541A820 modified at 0541A864 past
> > requested size of 3c
> >
> > I have tried using DUMA, a memory debugger, to shed any light but
> > unfortunately, it yields nothing. Sadly, I do not have access to purify.
> > Also the code is non-portable (don't ask) so I can't build it on linux
> and
> > use valgrind.
> >
> > The call stack looks like this:
> >
> >         ntdll.dll!7c90120e()
> >         [Frames below may be incorrect and/or missing, no symbols loaded
> > for ntdll.dll]
> >         ntdll.dll!7c96e139()
> >         ntdll.dll!7c95f38c()
> >         ntdll.dll!7c96e507()
> >         ntdll.dll!7c9622e8()
> >         ntdll.dll!7c90327a()
> >         kernel32.dll!7c85f9a7()
> >>       msvcr80d.dll!_CrtIsValidHeapPointer(const void *
> > pUserData=0x0541a848)  Line 2072        C++
> >         msvcr80d.dll!_free_dbg_nolock(void * pUserData=0x0541a848, int
> > nBlockUse=1)  Line 1279 + 0x9 bytes     C++
> >         msvcr80d.dll!_free_dbg(void * pUserData=0x0541a848, int
> > nBlockUse=1)  Line 1220 + 0xd bytes     C++
> >         msvcr80d.dll!operator delete(void * pUserData=0x0541a848)  Line
> 54
> > + 0x10 bytes    C++
> >         myprog.exe!xms::ConnectionFactory::setProperty()  + 0x78e bytes
> > C++
> >         myprog.exe!main(int argc=11, char * * argv=0x054172b0)  Line 457
> +
> > 0x10 bytes      C++
> >         myprog.exe!__tmainCRTStartup()  Line 597 + 0x19 bytes   C
> >         myprog.exe!mainCRTStartup()  Line 414   C
> >         kernel32.dll!7c817077()
> >
> > This is weird because I do not call ConnectionFactory::setProperty(), and
> > the only call I make to AMQ-cpp from main is the init call.
> >
> > The problem does not occur in Release mode. Unfortunately I need Debug
> > mode (for various reasons).
> >
> > Recently a bug was reported in AMQ-cpp to do with deadlocks that bites
> > Windows users. I am on the version that has that bug but I do not think
> > that bug is responsible for this.
> >
> > I am desperately in need of some help/guidance please.
> >
> > Regards,
> >
> > Andrew Marlow
> >
> > ___________________________________________________________
> > This e-mail may contain confidential and/or privileged information. If
> you
> > are not the intended recipient (or have received this e-mail in error)
> > please notify the sender immediately and delete this e-mail. Any
> > unauthorised copying, disclosure or distribution of the material in this
> > e-mail is prohibited.
> >
> > Please refer to
> >
> http://www.bnpparibas.co.uk/en/information/legal_information.asp?Code=ECAS-845C5H
> > for additional disclosures.
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/help-needed%3A-heap-corruption-when-activemq-cpp-routines-called-tp28900570p29157646.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>

Re: help needed: heap corruption when activemq-cpp routines called

Posted by "jolly.Wang" <wa...@163.com>.
I have the same problem. Here is the solution:
when in debug mode, use activemq-cppd.lib(don't use activemq-cpp.lib:
crash);when in release mode, use activemq-cpp.lib(don't use
activemq-cppd.lib)。



andrew.marlow wrote:
> 
> I have been seeing an intermittent heap corruption in my AMQ-cpp program, 
> on and of, for some time now. It happens right at the start when it calls 
> activemq::library::ActiveMQCPP::initializeLibrary(). Unfortunately, that 
> which was intermittent is now happening every time.
> 
> I am using AMQ-cpp 3.1.0 in Windows-XP SP3, with VS 2005 (aka vc8).
> 
> By moving this call to at the very start of main, the bug relocates -- it 
> then fails on this line of code:
> 
>  std::auto_ptr<activemq::core::ActiveMQConnectionFactory> 
> connectionFactory(
>         new activemq::core::ActiveMQConnectionFactory(queueManagerName));
> 
> The variable 'queueManagerName' is initialised correctly, it is set 
> to"tcp://127.0.0.1:61616".
> 
> Output from VS is not very helpful:
> 
> First-chance exception at 0x7c919084 in myprog.exe: 0xC0000005: Access 
> violation reading location 0x0000000f.
> First-chance exception at 0x7c812afb in myprog.exe: Microsoft C++ 
> exception: std::bad_alloc at memory location 0x0012ee7c..
> HEAP[myprog.exe]: Heap block at 0541A820 modified at 0541A864 past 
> requested size of 3c
> 
> I have tried using DUMA, a memory debugger, to shed any light but 
> unfortunately, it yields nothing. Sadly, I do not have access to purify. 
> Also the code is non-portable (don't ask) so I can't build it on linux and 
> use valgrind.
> 
> The call stack looks like this:
> 
>         ntdll.dll!7c90120e() 
>         [Frames below may be incorrect and/or missing, no symbols loaded 
> for ntdll.dll] 
>         ntdll.dll!7c96e139() 
>         ntdll.dll!7c95f38c() 
>         ntdll.dll!7c96e507() 
>         ntdll.dll!7c9622e8() 
>         ntdll.dll!7c90327a() 
>         kernel32.dll!7c85f9a7() 
>>       msvcr80d.dll!_CrtIsValidHeapPointer(const void * 
> pUserData=0x0541a848)  Line 2072        C++
>         msvcr80d.dll!_free_dbg_nolock(void * pUserData=0x0541a848, int 
> nBlockUse=1)  Line 1279 + 0x9 bytes     C++
>         msvcr80d.dll!_free_dbg(void * pUserData=0x0541a848, int 
> nBlockUse=1)  Line 1220 + 0xd bytes     C++
>         msvcr80d.dll!operator delete(void * pUserData=0x0541a848)  Line 54 
> + 0x10 bytes    C++
>         myprog.exe!xms::ConnectionFactory::setProperty()  + 0x78e bytes 
> C++
>         myprog.exe!main(int argc=11, char * * argv=0x054172b0)  Line 457 + 
> 0x10 bytes      C++
>         myprog.exe!__tmainCRTStartup()  Line 597 + 0x19 bytes   C
>         myprog.exe!mainCRTStartup()  Line 414   C
>         kernel32.dll!7c817077() 
> 
> This is weird because I do not call ConnectionFactory::setProperty(), and 
> the only call I make to AMQ-cpp from main is the init call.
> 
> The problem does not occur in Release mode. Unfortunately I need Debug 
> mode (for various reasons).
> 
> Recently a bug was reported in AMQ-cpp to do with deadlocks that bites 
> Windows users. I am on the version that has that bug but I do not think 
> that bug is responsible for this.
> 
> I am desperately in need of some help/guidance please.
> 
> Regards,
> 
> Andrew Marlow
> 
> ___________________________________________________________
> This e-mail may contain confidential and/or privileged information. If you
> are not the intended recipient (or have received this e-mail in error)
> please notify the sender immediately and delete this e-mail. Any
> unauthorised copying, disclosure or distribution of the material in this
> e-mail is prohibited.
> 
> Please refer to
> http://www.bnpparibas.co.uk/en/information/legal_information.asp?Code=ECAS-845C5H 
> for additional disclosures.
> 
> 

-- 
View this message in context: http://old.nabble.com/help-needed%3A-heap-corruption-when-activemq-cpp-routines-called-tp28900570p29157646.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: help needed: heap corruption when activemq-cpp routines called

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2010-06-16 at 10:08 +0100, andrew.marlow@uk.bnpparibas.com
wrote:
> I have been seeing an intermittent heap corruption in my AMQ-cpp program, 
> on and of, for some time now. It happens right at the start when it calls 
> activemq::library::ActiveMQCPP::initializeLibrary(). Unfortunately, that 
> which was intermittent is now happening every time.
> 
> I am using AMQ-cpp 3.1.0 in Windows-XP SP3, with VS 2005 (aka vc8).
> 
> By moving this call to at the very start of main, the bug relocates -- it 
> then fails on this line of code:
> 
>  std::auto_ptr<activemq::core::ActiveMQConnectionFactory> 
> connectionFactory(
>         new activemq::core::ActiveMQConnectionFactory(queueManagerName));
> 
> The variable 'queueManagerName' is initialised correctly, it is set 
> to"tcp://127.0.0.1:61616".
> 
> Output from VS is not very helpful:
> 
> First-chance exception at 0x7c919084 in myprog.exe: 0xC0000005: Access 
> violation reading location 0x0000000f.
> First-chance exception at 0x7c812afb in myprog.exe: Microsoft C++ 
> exception: std::bad_alloc at memory location 0x0012ee7c..
> HEAP[myprog.exe]: Heap block at 0541A820 modified at 0541A864 past 
> requested size of 3c
> 
> I have tried using DUMA, a memory debugger, to shed any light but 
> unfortunately, it yields nothing. Sadly, I do not have access to purify. 
> Also the code is non-portable (don't ask) so I can't build it on linux and 
> use valgrind.
> 
> The call stack looks like this:
> 
>         ntdll.dll!7c90120e() 
>         [Frames below may be incorrect and/or missing, no symbols loaded 
> for ntdll.dll] 
>         ntdll.dll!7c96e139() 
>         ntdll.dll!7c95f38c() 
>         ntdll.dll!7c96e507() 
>         ntdll.dll!7c9622e8() 
>         ntdll.dll!7c90327a() 
>         kernel32.dll!7c85f9a7() 
> >       msvcr80d.dll!_CrtIsValidHeapPointer(const void * 
> pUserData=0x0541a848)  Line 2072        C++
>         msvcr80d.dll!_free_dbg_nolock(void * pUserData=0x0541a848, int 
> nBlockUse=1)  Line 1279 + 0x9 bytes     C++
>         msvcr80d.dll!_free_dbg(void * pUserData=0x0541a848, int 
> nBlockUse=1)  Line 1220 + 0xd bytes     C++
>         msvcr80d.dll!operator delete(void * pUserData=0x0541a848)  Line 54 
> + 0x10 bytes    C++
>         myprog.exe!xms::ConnectionFactory::setProperty()  + 0x78e bytes 
> C++
>         myprog.exe!main(int argc=11, char * * argv=0x054172b0)  Line 457 + 
> 0x10 bytes      C++
>         myprog.exe!__tmainCRTStartup()  Line 597 + 0x19 bytes   C
>         myprog.exe!mainCRTStartup()  Line 414   C
>         kernel32.dll!7c817077() 
> 
> This is weird because I do not call ConnectionFactory::setProperty(), and 
> the only call I make to AMQ-cpp from main is the init call.
> 
> The problem does not occur in Release mode. Unfortunately I need Debug 
> mode (for various reasons).
> 
> Recently a bug was reported in AMQ-cpp to do with deadlocks that bites 
> Windows users. I am on the version that has that bug but I do not think 
> that bug is responsible for this.
> 
> I am desperately in need of some help/guidance please.

Can you provide a sample app that demonstrates the issue?  I've not see
this error before.


Regards


-- 
Tim Bish

Open Source Integration: http://fusesource.com
ActiveMQ in Action: http://www.manning.com/snyder/

Follow me on Twitter: http://twitter.com/tabish121
My Blog: http://timbish.blogspot.com/