You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Andrew Hartline <an...@gmail.com> on 2015/09/08 23:48:04 UTC

qpid-cpp: bad_allocs when using "empty" Message constructor within Boost test framework

Hi qpid users,

I have an interesting issue. In the qpid-cpp examples the following idiom
works to create a Message object on the stack.

        Message m;

This looks like it should be calling an empty constructor but in fact no
such constructor is defined. Instead it's calling this one:

        Message
<https://qpid.apache.org/releases/qpid-0.28/messaging-api/cpp/api/classqpid_1_1messaging_1_1Message.html#a10ceff23ff6fde62d9026fd13bc28662>
(const
std::string &bytes=std::string())

Creating a Message in this way works fine for me in the qpid-cpp examples,
but it throws a std::bad_alloc when I do it from within the Boost test
framework. I hypothesize that it has something to do with the construction
of the defaulted string, but don't know what the details could be.

If from inside the Boost framework,  I create a Message like so:

        qpid::types::Variant v(123);
        qpid::messaging::Message msg(v);

there is no bad_alloc.

Throwing in this dummy Variant is ok as a workaround, but I would love to
know what's going on under the hood. Does anyone have any idea why I might
be getting these bad_allocs?

Thanks,

Andrew

Re: qpid-cpp: bad_allocs when using "empty" Message constructor within Boost test framework

Posted by Andrew Hartline <an...@gmail.com>.
Got it --- there were some subtle linker problems that weren't errors, but
led to some of the dreaded undefined behaviour. Now that VS2013 knows
exactly where my .lib files are and which ones to use, all's well.

AH

On Tue, Sep 8, 2015 at 2:48 PM, Andrew Hartline <an...@gmail.com>
wrote:

> Hi qpid users,
>
> I have an interesting issue. In the qpid-cpp examples the following idiom
> works to create a Message object on the stack.
>
>         Message m;
>
> This looks like it should be calling an empty constructor but in fact no
> such constructor is defined. Instead it's calling this one:
>
>         Message
> <https://qpid.apache.org/releases/qpid-0.28/messaging-api/cpp/api/classqpid_1_1messaging_1_1Message.html#a10ceff23ff6fde62d9026fd13bc28662> (const
> std::string &bytes=std::string())
>
> Creating a Message in this way works fine for me in the qpid-cpp examples,
> but it throws a std::bad_alloc when I do it from within the Boost test
> framework. I hypothesize that it has something to do with the construction
> of the defaulted string, but don't know what the details could be.
>
> If from inside the Boost framework,  I create a Message like so:
>
>         qpid::types::Variant v(123);
>         qpid::messaging::Message msg(v);
>
> there is no bad_alloc.
>
> Throwing in this dummy Variant is ok as a workaround, but I would love to
> know what's going on under the hood. Does anyone have any idea why I might
> be getting these bad_allocs?
>
> Thanks,
>
> Andrew
>