• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

GDI+ SetDashPattern causes odd crash

JB3DG

Resource contributor
Messages
1,325
Country
southafrica
This one is for guys like virtuali and other GDI+ programmers.

Some of the users of my WX radar gauge are getting a really odd crash in the gauge constructor where I initialize the GDI+ objects in my gauge. It is an extremely rare error as hardly anyone gets it and I cannot replicate it. The only way I figured out where it was coming from was by tracing offsets in the disassembler in my dll.

Code:
        dPen = new Pen(Color(255, 94, 183, 255), 2);
        lBrush = new SolidBrush(Color(255, 94, 183, 255));
        REAL dv[4] = {3.0f, 4.0f, 3.0f, 4.0f};
        dPen->SetDashPattern(dv, 4);
        wxfont = new Font(L"Glass Gauge", 20.0f, FontStyleRegular, UnitPixel );
        wx2font = new Font(L"Arial", 20.0f, FontStyleRegular, UnitPixel );

The exact line is the dPen->SetDashPattern(dv, 4); call. I cannot fathom what could cause it to wrong for one person when it works for so many others.

Anyone got any ideas?
 
Just says access violation. Nothing else. 0xc0000005 on the windows error report.
 
You're not checking to see if those new operators are succeeding. What happens if FS chooses that particular moment to run out of VAS?
 
I can't imagine that would be the case here but good point....will add pointer protection.
 
Did you find any pattern in the reported bugs (system, used add-ons, FS version) ? Maybe it could give you some hint. Stack issues (e.g. due to unsafe thread code) could trigger 0xc0000005 error as well. I assume it is in process DLL. Sometimes I had some weird issues with EXE initialized via EXE.XML (only in P3D on W7-64 on very few machines)
 
All I did was put an if checking if dPen is a valid pointer before the SetDashPattern call. That stopped the crash.
 
Ah... so the actual problem isn't solved... just the crash. Just an FYI... if you pass a null pen to a GDI+ function, it doesn't crash... but it doesn't do anything either. So... if your pen isn't being created... while you've avoided the crash.... you won't be rendering with that NULL pen, whatever it's drawing.
 
That's the crazy part. The gauge still works. Something like the class being deleted and recreated twice in quick succession and the second time the call is successful. Without being able to remote debug on the user's computer I have no idea what is happening.
 
Back
Top