Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
NoelC

API Issues Under The Covers

Recommended Posts

With Windows 8 making "ugh, desktop" development unfashionable, and with obvious reductions in desktop functionality (e.g., the removal of Aero Glass, etc.), I've wondered whether the software may be suffering neglect under the covers, in the parts we don't see.

 

I can confirm that it is.  It's a trend that will spell the demise of Microsoft if left unchecked.

 

No, I'm not talking about the debacle with the August updates.

 

Lately I've been working to bring some software to release, and we have a LOT of instrumentation inside it to catch unexpected errors, leaks, etc.

 

With Windows 8.1 we're seeing a lot more unexplained system errors (the kind you can retrieve with GetLastError()) between events.

 

What I mean is this:  We get an event from Windows, do a GetLastError() call, and unexpectedly instead of ERROR_SUCCESS there's an error such as "Invalid Window Handle" or "Access Denied" just sitting in there.

 

This is a difference in behavior as compared to Windows 7 and earlier. 

 

That's not to say we never saw errors this way with Win 7, but for the most part when we did we were always able to trace them back to a particular source and actually DO something about it.  Sometimes it was the background code we are running, and occasionally it was a problem in a common control that's well-known.

 

Microsoft documents many of its API calls as setting the "last error" value if there's a problem, and specifically documents that the "last error" may not be cleared if a call succeeds, but in practice it's been rare that you get a success status back and GetLastError() returns something other than ERROR_SUCCESS.

 

Now there are whole new sets of these errors showing up with Windows 8.  Anyone who appreciates the rigor it takes to make an application work perfectly will see this for what it is - a very bad trend.  To me it indicates a whole new low level of discipline or possibly even lack of knowledge in Microsoft's technical ranks.

 

-Noel

Share this post


Link to post
Share on other sites

In very short... when some API returns success (e.g. TRUE or whatever it should return) then you should not rely on GetLastError() unless you manually called SetLastError before calling the API function.

Share this post


Link to post
Share on other sites

Right, I know that.  But my point here is very subtle.

 

Even though we have direct error checking, we also instrument our code to look for unexpected error codes cropping up anyway at the start and end of event handling, so as to pick up on any subtle errors our local error handling may have missed.

 

In the past we've always been able to get to the bottom of why such errors show up, and eliminate them.  It makes the code more robust.  Problem is, there's a whole new set with Windows 8 and it's starting to look like we're not going to be able to eliminate them all.

 

That tells us subtle things about the robustness of the operating system.

 

-Noel

Share this post


Link to post
Share on other sites

I don't think it means much. No point in expecting undocumented behavior to stay. You might even call it counter-documented.

 

Who knows, maybe it's some sort of internal optimization to not set the error code to 0. You might step into it in 8 vs 7 and see what changed. :)

 

BTW, did you try running it in the various compatibility modes?

Edited by shae

Share this post


Link to post
Share on other sites

I'm sure it's not a problem, per se, but I see it as a possible minor insight into the minds and culture of Microsoft.

 

I have compared it with Win 7 and there are quite a bit fewer errors showing up there.

 

No, I haven't run it in compatibility mode as it shouldn't need it.

 

-Noel

Edited by NoelC

Share this post


Link to post
Share on other sites

Perhaps Windows 8 are more verbal than Windows 7 and report everything even if it is trivial.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...