Boost logo

Boost Users :

From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2007-09-18 23:43:52


Sounds exactly like what I've seen.

It is because of alignment/packing differences.

boost.threads enforces 8 byte alignment using boost ABI headers.
boost.function does not - it uses whatever alignment you have set up.

previous versions of function<> didn't have alignment issues - it
started with the small object optimizations.

I think the fix is to force is to have function enforce alignment the
same way threads does, although I'm still contemplating the
'philosophical ramifications'.

Tony

On 8/7/07, Jaime Rios <xdev74_at_[hidden]> wrote:
> Hi,
> I'm working on a project that uses the Boost thread library. The code is
> pretty simple and creates one thread to a function. To test out the code I
> created, I create a console app and tested the code on 2 platforms: Mac OS X
> for Intel and Mac OS X for PowerPC. The code worked fine in the console app
> so I incorporated the code into my main project, which is a dylib. The code
> worked fine on the Intel Mac, but when I debugged the dylib on the PowerPC
> Mac, I get a EXC_BAD_ACCESS error.
>
> After spending many hours trying to find out what the cause of the problem
> is, the only thing I could derive was that the address that Boost was using
> to access my function was wrong. Before the error, I have the following
> address to my function:
>
> (gdb) print f
> $1 = (void (*)(void)) 0x33658e4 <MyWorkerThread()>
>
> When I get the EXC_BAD_ACCESS error, the debugger stops at the following
> line:
>
> On line 95 of file function_template.hpp
> struct BOOST_FUNCTION_VOID_FUNCTION
> _INVOKER
> {
> static BOOST_FUNCTION_VOID_RETURN_TYPE
> invoke(any_pointer function_ptr BOOST_FUNCTION_COMMA
> BOOST_FUNCTION_PARMS)
>
> {
> HERE--> FunctionPtr f =
> reinterpret_cast<FunctionPtr>(function_ptr.func_ptr);
> BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));
> }
> };
>
> The address at this point is the following:
>
> (gdb) print f
> $2 = (void (*)(void)) 0xf0798dd0
>
> I went over the code over and over again but I cannot figure out what is
> causing the original function address to be changed.
>
> Now for the question! How can I debug this better? The problem that I am
> finding is that my debugger jumps to different parts of the project, but I
> cannot pinpoint the actual code that is causing this problem. Any
> suggestions? Thanks in advance!
>
>
> -Jaime
> _______________________________________________
> 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