c++ - boost::intrusive_ptr changing pointer address -


i have base class provides intrusive_ptr_add_ref , intrusive_ptr_release subclasses use boost::intrusive_ptr.

the code in question works 100% on macos x , linux. on windows (visual studio 2010, 64-bit relwithdebinfo optimizations disabled), works classes, breaks on 1 particular subclass (nothing weird or special it). have sequence of events stopped in debugger type this:

1. t * t = get_pointer_from_lua(); // correct value returned: 0x..7a38 2. boost::intrusive_ptr p(t); // ... , passed in here 

... , in ensuing intrusive_ptr_add_ref, value of pointer 0x..7a40. 8 bytes ahead. i'm looking @ stack trace right - 0x..38 goes intrusive_ptr's constructor, hits reference increment function 0x..40.

how can figure out what's happening here? third party libraries release builds, can't trace intrusive_ptr - can't imagine it's blatantly broken.

i'm @ end of rope here. suggestions?

edit: after posted this, obvious alignment issue jumped out @ me. maybe intrusive_ptr requires 16-byte alignment on windows? pointer not directly allocated, returned lua's memory manager. off google...

on further investigation, able duplicate issue on macos x, adding field base class , making non-zero-sized. there, tracked down obscure situation involving multiple inheritance (elsewhere in tree, no less!), casting base class can change value of pointer!


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -