Boost logo

Boost Users :

Subject: Re: [Boost-users] [pool] singlton_pool::malloc returning bad address
From: Jonathan Leonard (v-jleonard_at_[hidden])
Date: 2009-07-02 20:38:01


AMDG

It's called with 5 different data structures (all with a different size). I'm not exactly sure the distribution of these but can measure it if that would be of use. Here are the [obfuscated but structurally-equivalent] types:

struct T1
{
        C* _p;
        boost::function<void (int, bool)> _f;
        unsigned __int64 _offset1;
        unsigned __int64 _offset2;
        boost::shared_ptr<std::vector<BYTE, VirtualAllocator<BYTE>>> _vec;
};

struct T2
{
        boost::function<void (bool)> _f;
};

struct T3
{
        C* _p;
        C* _p2;
};

struct T4
{
        C* _p;
        C* _p2;
        unsigned int _i;
        unsigned int _i2;
        C* _p3;
        unsigned int _i3;
        C* _p4;
        int _i4;
};

struct T5
{
        C* _p;
        int _i;
        int _i2;
        unsigned int _i3;
        unsigned int _i4;
};

--Jonathan

-----Original Message-----
From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Steven Watanabe
Sent: Thursday, July 02, 2009 3:47 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [pool] singlton_pool::malloc returning bad address

AMDG

Jonathan Leonard wrote:
> I'm just using the default specialization like such:
>
> struct scalable_alloc_tag {};
> T* ret = (T*)boost::singleton_pool<scalable_alloc_tag, sizeof(T)>::malloc();
> if (!ret)
> throw std::bad_alloc();
>
> new (ret) T();
>

What is sizeof(T)?

> Yep, malloc and free are being called simultaneously from the main thread and worker threads. The docs say that it is thread-safe "if there is only one thread running before main() begins and after main() ends" [which is our case].
>

Okay. Yes. The default specialization should be thread-safe.
It doesn't look like there is any way for the implementation to
be bad in that respect since it simply locks around every operation.
Just to be pedantic, you might check to make sure that
BOOST_NO_MT is not defined after including any pool headers.

> A rough calculation shows that approx 8.64 billion alloc/free pairs occurred before the crash.
>

Okay, that's way more than my brief test got to.

In Christ,
Steven Watanabe

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net