Lisbon would be ideal for 3 days. Easy and not expensive to fly to (on TAP or Vueling). And I find it more interesting than Malaga.
You could consider Madrid, but it can be really cold there. Or Valencia, but that's probably too similar to Barcelona.
And concerning your Gibraltar idea: it's even too boring for 3 hours.