
*sighs* This has nothing to do with boost. I meant to have: memcpy( &ret, this->bytes.get(), sizeof(ether_header) ) ; Thanks for point that out. It must have been over-writing part of a shared_ptr on the stack. Ah, well at least I feel good that my understanding of shared_ptrs isn't wrong. :-) Thanks everyone, David
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Peter Dimov Sent: Tuesday, May 18, 2010 1:27 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] shared_ptr question
David Michael Bond wrote: ...
I looked into it more and it seems if I comment out the memcpy in the get_ether_header function I do not get the segfault.
ether_header Frame::get_ether_header( ) { ether_header ret ; memcpy( &ret, this->bytes.get(), this->size ) ; return ret ; }
Its fine to return that stack var right there right? That should just copy the memory into the return value for the stack?
It's fine to return a stack variable, but it may not be fine to memcpy into it, depending on how ether_header is defined and whether this->size may exceed sizeof(ether_header).
To investigate further, you might want to look at the stack backtrace when the segfault occurs. Your shared_ptr use seems fine, so it's probably ~Frame that is crashing (unless there is memory damage).
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users