Was this an All Grain brew, or Extract? Was the flavor apparent from the start, or did it develop over time?
Brewing All Grain pale-to-amber beers is pretty easy. If your water isn't slap full of chlorine/iron/etc (ie, tastes pretty good) then you can happily brew away without a care in the world. And a lot of all grain brewers make great beer .... up until they try their first Porter or Stout. What started out as a solid, good tasting Porter/Stout extract recipe now tastes like chalk/ashes. Why?
I'm not really a water chemistry expert, but here's how I understand it. When you mash really dark grains (Chocolate, Roast Barley, Carafa, very dark Crystal, etc), these grains really drag down your mash pH to levels that can really promote "astringent" flavors in the final beer. Actually, the longer the maltster toasts the grain, the lower the mash pH will be if you use that grain. However, with most base malts + most crystal malts less than, say, 80L, this impact is minimal. But if you've got enough roasted malt in your mash to bring down the pH past a certain threshold, then you can end up with the dreaded "ash tray" flavor.
You can get very, very fancy in your approach to solving this. The "best practice" for serious brewers is to get the highly regarded "Bru'n Water" spreadsheet and use it to calculate the proper mineral additions to keep your water chemistry in check. https://sites.google.com/site/brunwater/. You'll need to know the "profile" of your starting water.
You can also use the easier "EZ Water Calculator". I personally use this, and it seems to work fine, but honestly, I never brew much darker than a roasty Brown Ale from time to time. http://www.ezwatercalculator.com/
Finally, there's another approach, which is espoused by Gordon Strong, wherein you say "screw it!" to all these water calculations and do a few things. 1) Start with 100% reverse osmosis water. 2) Don't add dark grains to the mash, steep them separately and add to the boil. 3) Add a standard amount of calcium chloride to each brew, and a little gypsum for hoppy beers. These rules of thumb will get you good beers regularly. You might need to tweak recipes slightly with this approach, as your dark grains won't add as much color/flavor as they otherwise might have.
Whew... but what if this doesn't fix the problem? Or what if your dark beers tasted fine for a few weeks, and then slowly developed the ashy taste? (I had this happen to an Oatmeal Porter not too long ago). In that case, you've probably got an infection, ESPECIALLY if the beers are extra foamy. In dark beers, the acidity from an infection can come through as a rough/chalky/astringent flavor, whereas in lighter beers it might just taste weird/fruity/tangy. So that's a distinct possibility as well.