Boost logo

Boost Users :

From: kauai (kauai_diver_at_[hidden])
Date: 2005-05-11 13:35:29


Hi Robert et all,

Ok details. Now that I am able to compile/link/run using
that macro Jeff provided I can move on.

Quick summary, for legacy reasons we have a structure
called ByteArray passed around everywhere. It is simply a
public class like this:
class ByteArray
{
public:
   unsigned char *pArray;
   int length;
   int offset;
}

On our receiving side we have a piece of code like this:

// The function argument(s) have to be like this
unfortunately. Also pArray is serialized by the sender
with code like this but using binary_oarchive
OrderedCollection*
OrderedCollection::GetOrderedCollection(ByteArray *pArray)
// this is a static method, pArray points to valid heap
memory
{
   OrderedCollection *pCollection = NULL;
   std::string astring ((char*) (pArray->pData),
pArray->length + pArray->offset);

   std::istringstream iss(astring);
   boost::archive::binary_iarchive ia(iss); // exception
here in Windows not Linux, below is the reason and call
stack
   is << BOOST_SERIALIZATION_NVP(pCollection);
   return pCollection;
}

Again this works in Linux, and I've run it through Valgrind
(a linux tool) with no errors or leaks. If there is a
better way to construct a binary input archive I'd like to
know, im new to stl classes.

I get a std::bad_alloc exception, here is the call stack:

 
cmnTest2.exe!boost::archive::basic_binary_iprimitive<boost::archive::binary_iarchive,std::basic_istream<char,std::char_traits<char>
>
>::load(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> & s={...}) Line 93 C++
>
cmnTest2.exe!boost::archive::load_access::load_primitive<boost::archive::binary_iarchive,std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >(boost::archive::binary_iarchive & ar={...},
std::basic_string<char,std::char_traits<char>,std::allocator<char>
> & t={...}) Line 96 C++

 
cmnTest2.exe!boost::archive::detail::load_non_pointer_type<boost::archive::binary_iarchive,std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >::load_primitive::invoke(boost::archive::binary_iarchive
& ar={...},
std::basic_string<char,std::char_traits<char>,std::allocator<char>
> & t={...}) Line 308 + 0xd C++

 
cmnTest2.exe!boost::archive::detail::load_non_pointer_type<boost::archive::binary_iarchive,std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >::invoke(boost::archive::binary_iarchive & ar={...},
std::basic_string<char,std::char_traits<char>,std::allocator<char>
> & t={...}) Line 366 + 0xd C++

 
cmnTest2.exe!boost::archive::load<boost::archive::binary_iarchive,std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >(boost::archive::binary_iarchive & ar={...},
std::basic_string<char,std::char_traits<char>,std::allocator<char>
> & t={...}) Line 529 + 0xd C++

 
cmnTest2.exe!boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::load_override<std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >() Line 66 + 0x15 C++

 
cmnTest2.exe!boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive>::load_override<std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >() Line 46 C++

 
cmnTest2.exe!boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><std::basic_string<char,std::char_traits<char>,std::allocator<char>
>
>(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> & t={...}) Line 84 C++

 
cmnTest2.exe!boost::archive::detail::common_iarchive<boost::archive::binary_iarchive>::init()
 Line 66 C++

 
cmnTest2.exe!boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive>::binary_iarchive_impl<boost::archive::binary_iarchive>(std::basic_istream<char,std::char_traits<char>
> & is={...}, unsigned int flags=0) Line 60 C++

 
cmnTest2.exe!boost::archive::binary_iarchive::binary_iarchive(std::basic_istream<char,std::char_traits<char>
> & is={...}, unsigned int flags=0) Line 78 + 0x1e C++

 
cmnTest2.exe!OrderedCollection::GetOrderedCollection(ByteArray
* pArray=0x0034c620) Line 111 + 0x14 C++

Thanks,
Kauai

--- kauai <kauai_diver_at_[hidden]> wrote:
> Date: Wed, 11 May 2005 10:15:34 -0700 (PDT)
> From: kauai <kauai_diver_at_[hidden]>
> Subject: Re: [Boost-users] Re: Re: Re: Re: Boost
> serializationanddependencynightmares...
> To: boost-users_at_[hidden]
>
>
> Hi Robert, Jeff, et all,
>
> Thank you Jeff, using that macro helped, I can now build
> with the Microsoft compiler. Now getting some sort of
> exception in my serialization code.
>
> I am looking into that today, have to setup my visual
> studio and debugger :) And will get back to you all a
> bit
> later...
>
> Thanks,
> K
>
>
> --- Robert Ramey <ramey_at_[hidden]> wrote:
> > For what its worth, changes have been made for 1.33
> which
> > work better with
> > argument dependent lookup as well as two-phase lookup.
> >
> > I envisioned that the EXPORT marcros be in the class
> > header after the class
> > declaration.
> >
> > For export to work properly, the archive includes have
> to
> > before the class
> > heades with EXPORT in them
> >
> > All serialization traites macros like EXPORT must be
> > invoke from the global
> > namespace.
> >
> > Robert Ramey
> >
> >
> > Jeff Flinn wrote:
> > > "kauai" <kauai_diver_at_[hidden]> wrote in message
> > >
> >
>
news:20050510182406.59092.qmail_at_web60712.mail.yahoo.com...
> > >> Hi Robert,
> > >>
> > >> The EXPORT macros were initially inside a namespace,
> > >> interesting that it compiled and linked with gcc.
> > >>
> > >> After fixing this I still have the same problem with
> > >> Microsofts compiler. It complains about the same
> > thing as
> > >> I state below. Is there some include file that I
> may
> > be
> > >> missing? I can send you some code if that helps.
> > >
> > > I use:
> > >
> > > #define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
> > >
> > > previous to including any boost serialization
> headers.
> > I'm not sure
> > > it'll solve your issues, but it did with mine with
> > VC7.1.
> > >
> > > Jeff Flinn
> >
> >
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
>
>
>
> __________________________________
> Yahoo! Mail Mobile
> Take Yahoo! Mail with you! Check email on your mobile
> phone.
> http://mobile.yahoo.com/learn/mail
>

                
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html


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