Code that works on another platform, not with CrossWorks

Comments

5 comments

  • Avatar
    Michael Johnson

    Stack size?

    0
    Comment actions Permalink
  • Avatar
    stevek80

    Weird !

    The stuff now works.

    Change: The one static object inside the one (also static) member function is now a static member of the class, and initialized outside the class def (which I was too lazy to do before).

    This object happens to be my allocator, which gave always the same address for each in a sequence of allocation requests, because the correctly set to "used" marker bits, which would mark blocks as used, would be zero again on next call - as if the implementation wasn't really done static, and thus, the marker bits set to zero again each time ...

    Since this worked fine on MSVC++, I wonder: does GCC handle this differently from MSVC, is this standards gray area or did I do anything wrong?

    To illustrate:


    class List
    {
    private:

     class Node
     {
        static Node* Create()
        {
            Node* n = allocator_instance().Allocate();
            n->SetThoseAndTheseValues();
            return n;
        }
     };

    // does not work on crossworks/stm32, gives always same address (first block), since markers all zero.
    // On MSVC++, this works fine.
    //static Allocator<Node> & allocator_instance()
    //{
    //    static Allocator<Node> alloc;
    //    return alloc;
    // }
     
     
     // this works
     static Allocator<Node> alloc;
     
     static Allocator<Node> & allocator_instance()
     {    
        return alloc;
     } 
    };

    Now, this is simplified a lot, the allocator thingy is quite woven into templat-o-mania, but the only difference between works vs. doesn't work was the location change of the static variable.

    Ah, just read the new post: Stack size was 1024.

    I'll do some exteded tests whether this is really fine and dandy, and not just for some reason the couple tests passing...
    and post the results here later, maybe some people besides me finds that interesting :-)

    0
    Comment actions Permalink
  • Avatar
    stevek80

    Confirmed:

    I put a global counter inside the ctor of Allcoator...
    On the CrossWorks/GCC version, the constructor of Allocator gets called for each time allocator_instance() is called, in the version with static Allocator<Node> alloc; inside the static function.
    I'd say, this should not be happening, am I missing something?

    I just replicated this behavior with simple classes, without any template stuff going on behind the scenes.

    0
    Comment actions Permalink
  • Avatar
    Michael Johnson

    Something has to set the bottom bit of the guard object - see http://infocenter.arm.com/help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf

    I guess your empty __cxa_guard_acquire/release implementations need to be filled out a bit.....

    0
    Comment actions Permalink
  • Avatar
    stevek80

    Heh, d'oh! That was quite helpful, thanks a lot for the link!

    0
    Comment actions Permalink

Please sign in to leave a comment.