Jump to content

  • Log In with Google      Sign In   
  • Create Account


irreversible

Member Since 10 Nov 2005
Online Last Active Today, 05:50 AM
-----

Topics I've Started

Exception handling, debugging a custom memory allocator and working with first-chance e...

30 June 2014 - 10:39 AM

The problem: I've been working on and fleshing out my codebase for several years now and a vast majority of the time it works as expected. Nevertheless, there are occasional oddball situations that can easily lead to bug hunts that last for several days and often result in my finding various (seemingly) unrelated bugs that often also solve the problem at hand, but in a very obscure way. In such situations I often have nothing more to do than shrug and carry as if something so inexplicable happened that it defied the laws of physics. Some of this has to do with code complexity; however, I suspect more than that, this has to do with my knowledge of how to handle these situations.

 

The setup: I'm writing a multi-threaded application that currently branches into two primary threads - the render thread and the input thread. Both have SEH exception handlers at the stem: surrounding the entire body of code in the render thread and in the WNDPROC callback in the input thread. I'm catching all standard exceptions.

 

Where it gets complicated: every now and then I stumble upon a first-chance exception that throws off my entire program. Now, I know what a first-chance exception is and I know why it's being thrown the way it is. However, the root cause for it is usually an access violation, which is always terminal in nature. Using the Disassembly window I can look up what's at the address where the exception is thrown, but generally the it seems to be thrown in unmapped address space, which a) doesn't really help with pinpointing the cause and b) gives no indication as to where where or when it was thrown.

 

Where it gets more complicated: I'm using a custom memory allocator that I wrote. Is it bug-free? Good question. The bottom line is, it's not too complicated and doesn't support fancier features like reference counting or compaction. But it's fast, multithreaded and it gets the job done. At least as far as I can tell. It also makes debugging considerably more obscure.

 

The confusion: here's a very short snippet of code that exemplifies a common case of confusion. The following is a response to keyboard input and crashes always in the same way at the same moment. I've gone over the code preceding it and I can't find anything that might write into an invalid memory address (directly or remotely via another thread). I do recognize that this kind of inspection is concessional and doesn't really guarantee that I didn't miss a bug. Nevertheless, this is still a fairly strong indicator that by all logic the access violation cannot occur in any other thread (since it's temporally locked to user input) and has a low probability of occurring sometime before the below snippet is executed. This, in turn, completely screws up any and all logic when it comes to tracking down the cause:

int Editor::HandleKeyboardInput(...)
{
   ...
   if(toolActive) { toolActive->Activate(false); }
      toolActive = newTool;
   if(toolActive) //all cool in the Watch window
      toolActive->Activate(true); //BOOM! crash, because all of a sudden the 'this' pointer is NULL!
                                  //EDIT: apparently the 'this' pointer is modified only occasionally; other times newTool's
                                  //Activate() starts pointing to unmapped space
}

Running the debugger through this with application-side exception handling disabled just gives me an infinite loop of first-chance and second-chance exceptions that point to exotic memory addresses.

 

The solution? I've gone back to manually commenting out code blocks and ultimately it's not impossible to arrange code in a way that gets rid of the exception. However, the logic, which surrounds tracking something like this down still eludes me and I find myself resorting to trial and error, which frankly has a really poor probability of identifying and fixing the actual error that's causing this. After all, I've gone over everything ten times now and most permutations that do get ride of the crash (at least in terms of how I rearrange my code) don't make much sense.

 

So, to recap - if anyone can point out glaring holes in the way I'm handling exceptions in my code, comment or criticize on the way I'm tracking them down or provide overall suggestions, I'd appreciate it a lot. I realize the problem is likely something as silly as writing past a an array boundary (even though I'm using guarded arrays in debug mode...), but experience has proven that the more innocuous the bug, the more days or weeks it takes to track down.

 

Oh - in case it becomes relevant, I'm on VS2010, Windows 8.1.


pricing (using Visual Studio 2013 as an example)

17 June 2014 - 11:10 AM

I've been browsing for an affordable copy of VS2013 lately and quite frankly by now I'm feeling rather sad.

 

First off - I want Professional without MSDN. I have 2010, so I'm not eligible for the upgrade path, which only works from 2012. Hence I'm looking at a full purchase.

 

This is where it gets dicey.

 

I live in Europe. I know US prices are listed w/o tax, but the price for a full copy of VS from the MS store is more expensive in euros than it is in US dollars. That's no tax difference - at best, that's a ripoff or some EU sanctions crap that makes me feel like a third world citizen. In short, the price tag I'm looking at hovers a bit below €650 for VS2013 Pro without MSDN. If I want to get it from an official retailer.

 

 

 

I'm a hobbyist programmer who enjoys getting with the times and I pride myself with having managed to make myself completely legit since I started earning my own money. But this, frankly, is the kind of money I do not want to pay for a hobby. This is the kind of money that actually cuts into my food budget. As that alone weren't enough - my standard licence VAX won't migrate to 2013, so I'd have to shell out another 80 odd bucks for that as well.

 

Worst of all, there seems to be no way to take a shortcut. eBay and Amazon do sell it, but Amazon is not any cheaper and quite frankly I don't trust anything below the official store price on eBay. Especially the £120 key-only sellers who claim to have obtained their keys from bankrupt companies.

 

I know this pseudo rant won't get me anything, but I would still like the opportunity to draw attention to the rather outrageous pricing model a lot of companies are employing around the world. Beatport comes to mind. Tech companies - especially anything to do with A/V equipment that also provide full warranty come to mind (as far as Europe is concerned, Thomann is the only company I trust for audio equipment; and there's literally no good place to purchase video equipment from). I'm not sure about Steam pricing in the US, but games and films in stores cost A LOT where I live. A lot more than on Amazon and especially Amazon US. Amazon UK at least provides cheap delivery for UK residents - the rest of Europe can either look at Amazon DE (which as far as I can tell is ridiculously overpriced) or just lick it.

 

The only company I can think of off the top of my head that provides flat pricing is GoG.

 

In this light Adobe and Office 365 style subscription-based pricing models seem much more in tune with what a small fry such as myself can afford. As a hobbyist developer I could afford (and wouldn't mind paying) €15/month for VS.

 

Note that this thread has no purpose. I'm just saying things none of my friends wouldn't really know to do more about than grunt and move along.

 

tl;dr - tractors?

 

 


MSVC 2010 solution/project folder points to the wrong place (OneDrive/SkyDrive issue) (...

10 June 2014 - 12:41 PM

Edit: not sure what happened there; I solved it with a combination of reinstalling OneDrive and moving the code folder out of and back to its folder...

 

Original post was as follows:

 

 

The below may be somewhat confusing (it confuses me, too), but please stick with me smile.png.

 

Let me start by saying that I'm running the IDE on a new setup and my source code is stored inside the OneDrive folder (that is, the setup is a couple of months old, but I just got around to setting up my coding environment).

 

Googling tells me this is likely a source control issue and that I should edit the properties of my workspace to fix this (in MSVC, File->Source Control). However, I've never set up any workspaces and one doesn't seem to exist in the source control dialog. At best it prompts me to connect to a team foundation server, but there's no local setup. In fact, I've never had prior need to toy around with anything like this as I've always been a hobbyist.

 

The bottom line is that it would seem that OneDrive has set up some form of folder aliasing whereby the old SkyDrive folder sometimes points to the correct (now renamed) OneDrive path (eg when saving a source file it displays the old name, but saves to the correct location), but not when compiling (which generates a "cannot open file" error). Neither can I navigate to files that use project include paths (eg I can navigate to "../Common/common.h", but not "common.h", because the IDE looks for it in the SkyDrive folder, even though the include path is set up as ".../Common").

 

As far as I can tell all my environment variables should be set up properly and solution/project paths strictly relative. I've gone through the .sln and .vcproj files with a fine tooth comb using a text editor and neither includes any outdated references to the SkyDrive folder or, for that matter, absolute directories.

 

For reference, the offending folders in question are:

 

C:/Users/Username/SkyDrive/... (where OneDrive used to be before  it was renamed)

C:/Users/Username/OneDrive/... (where it is now)

 

Since as far as I can tell Windows 8.1 forces the OneDrive folder to have this name and be in this location, I don't think I can rename it either.

 

This is very frustrating. What am I missing here?


Increasing IOTD interaction

01 June 2014 - 03:44 PM

I love IOTD. I don't go out looking for it, but it frequently catches my attention on the right pane and I think that's a good thing. However, one major gripe I have with the feature is that these often wonderful looking screenshots are displayed at such appallingly low resolution in the preview window that it takes away most of the magic. Can't the default display size be made larger? When I click on it, I'm okay with it going full screen for me.

 

Anyways - that's not my suggestion. My suggestion has to do with interactivity.

 

Most of the IOTD candidates don't get many comments (if any). To be honest I haven't kept track, because the comments section seems to be pretty dud. So my suggestion is to alter it a bit to take away some of the chore of actually having to write up a sentence (or rather add to this option). If you're a user of ViewBug (requires registration/linking with FB to get access to the main features, I think), you'll be familiar with the awards system whereby each member can grant any image one of a variety of awards (eg "Jaw Dropping", "Top Choice", "Outstanding Creativity" etc). I don't think there's a limit to the number of awards a member can give out to different images, but it does present a very simple and constructive way of focusing community feedback. Don't want to leave another lame comment that says "great!"? Just give the image an award.

 

This might be one of those in-your-face features here on GD that largely replaces the comments section in IOTD. It would also allow images to be further ranked - not just by vote, but by type or style.


The Inspiration Thread™

20 May 2014 - 12:37 PM

Post links to music, visuals, pictures, game footage, books, poems, strange stuff, weird stuff, stuff that only makes sense to you, stuff you've bookmarked for some weird reason without knowing if you're ever going to look at it again, but you feel like it just deserves a bookmark. Or basically whatever you wish to - as long as you feel like that something has at one point inspired you.

 

Also - post a short snippet describing what it is in each of these nuggets that makes it special to you. That is, if you feel like it. Or don't. Just try to be inspired and inspire others.

 

 

 

 

 

My first entry belongs to the game Pencilwhipped - a hand-drawn first person shooter that I never got into, but I haven't been able to forget since I saw it more than ten years ago.

 

 

 

My second entry goes to this song - simply because of the way I it captures my imagination.

 

 

 

My third entry belongs to the first (so far really only) demo that made my jaw drop. Things go bonkers when it gets to the scroller. This is the first 64 kB demo I ever saw, way back in 2001 (the demo is from 2000).

 

 

A considerable selection from Arvo Pärt's repertoire. The cello rendition of his Fratres for the film There Will Be Blood is a particularly chilling example.

 

 

The 42 second drop from atop The Sunspire in Unreal back in 1999.

TheSunspire.jpg

 

I'm not sure why, but the track Empty Cans by The Streets has always inspired me. Probably because it exemplifies how everything that goes wrong can be turned completely around by a simple change in perspective.

 


PARTNERS