I think the audience for the joke has a lot to do with it, which is why the advent of mass communication for the masses is bluring the lines.
As an example, someone might make a joke about a terrible incident, like the recent Cumbrian shootings. If A makes a Joke about it to B and C fce t face down the pub, then it's likely that Mr A will only have told people the joke if he thinks they will take it the right way. If B or C had a relative die in the incident then A wouldn't have told them the joke unless A is an idiot or knows his friends will take it.
Scale that up to telling the same gag in a stand up slot in London, and A may still feel pretty safe, but the odds may be higher or him having an audience member or two who knew people involved in the event, or perhaps knew someone killed in an unrelated random shooting and are upset by the reference. The comic may still get chinned or made to feel like a git in person, so it's still personal enough to allow the comic to use some judgement in where to go with the gag.
Now try out the same gag on national TV and there's a good chance that you are going to offend a lot of people who were involved in the incident, and it would seem to be a no brainer to avoid that.
But what happens if the standup makes the gag to a small crowd in London or on the internet then the joke gets relayed through six degrees of separation via the internet? Suddenly massive offense is caused when the comic thought they had targeted their audience.
And it's not just comics. I'm told that members of the emergency services can have a pretty robust sense of humour about events just to vent steam, but I'm sure they wouldn't want much of what's said in the canteen to go beyond there.
If you are worried that it's questionable humour, then keep it between mates. If you think it may be ok in a wider context then use it, but prepared to say sorry or take it on the chin if it goes badly wrong.