From what I''ve read, most international cruisers don''t recommend carrying a firearm onboard. Besides the very real possibility of being thrown in jail by not-so-nice local police, there is also the likelihood that by brandishing your weapon, you may encite an escalated response from perpetrator(s).
Also, if the weapon accidently discharges it could cause bodily harm to you or your crew, not to mention the fact that it may put a hole in the hull which will need immediate repair if it''s below the waterline. :^(
I think the movie "Bowling for Columbine" may provide further insite.
BTW, there are other legal ways of providing self protection while onboard. Some have already mentioned, knives and spearguns, but we should all carry a flare-gun too. Remeber the movie "Dead Calm"? Now that was scary!
~ Happy sails to you ~ _/) ~