views:

47

answers:

1

Hello there, i'm on this bug for a week now, and i can't solve it. I have some crash with coregraphic calls, it happen randomly (sometimes after 2 mn, or just at the start), but often at the same places in the code.

I have a class that just wrap a CGContext, it have a CGContextRef as member. This Object is re-created each time DrawRect() is called, so the CGContextRef is always up-to-date. The draw calls came from the main thread, only

After looking for this kind of error, it appear that it should be object Release related.

Here is an example of an error :

#0 0x90d8a7a7 in ___forwarding___
#1 0x90d8a8b2 in __forwarding_prep_0___
#2 0x90d0d0b6 in CFRetain
#3 0x95e54a5d in CGColorRetain
#4 0x95e5491d in CGGStateCreateCopy
#5 0x95e5486d in CGGStackSave
#6 0x95e54846 in CGContextSaveGState
#7 0x00073500 in CAutoContextState::CAutoContextState at Context.cpp:47

the AutoContextSave() class look like this :

class CAutoContextState

{

private:

 CGContextRef m_Hdc;

public:

 CAutoContextState(const CGContextRef& Hdc)
 {
  m_Hdc = Hdc;
  CGContextSaveGState(m_Hdc);
 }

 virtual ~CAutoContextState()
 {
  CGContextRestoreGState(m_Hdc);
 }
};

It crash at CGContextSaveGState(m_Hdc).

Here is what i see into GDB: * -[Not A Type retain]: message sent to deallocated instance 0x16a148b0.

When i type malloc-history on the address, i have this :

0: 0x954cf10c in malloc_zone_malloc
    1: 0x90d0d201 in _CFRuntimeCreateInstance
    2: 0x95e3fe88 in CGTypeCreateInstanceWithAllocator
    3: 0x95e44297 in CGTypeCreateInstance
    4: 0x95e58f57 in CGColorCreate
    5: 0x71fdd in _ZN4Flux4Draw8CContext10DrawStringERKNS_7CStringEPKNS0_5CFontEPKNS0_6CBrushERKNS_5CRectENS0_12tagAlignmentESE_NS0_17tagStringTrimmingEfiPKf at /Volumes/Sources Mac/Flux/Sources/DotFlux/Projects/../Draw/CoreGraphic/Context.cpp:1029

Which point me at this line of code :

f32 components[] = {pSolidBrush->GetColor().GetfRed(), pSolidBrush->GetColor().GetfGreen(), pSolidBrush->GetColor().GetfBlue(), pSolidBrush->GetColor().GetfAlpha()}; //{ 1.0, 0.0, 0.0, 0.8 };
  CGColorRef TextColor = CGColorCreate(rgbColorSpace, components);

Point this func : CGColorCreate();

Any help would be appreciated, i need to finish this task very soon, but i don't know how to resolve this :(

Thanks.

A: 

Hello, finally find the CFRelease that cause this crash. Thanks

Ziggy