English sentences can often be ambiguous. Your first sentence has more ambiguity than just that - was it the boy who was "with a gun", or did they talk "with a gun"? In that case, it's reasonably obvious which it is. A lot of ambiguity is resolved with semantics - only some interpretations make sense - or with context - other sentences nearby make it clear which interpretation is intended.
It's hard to completely avoid grammatical ambiguity. Sometimes you can do it with a rephrase, or with commas to make it clear that there's a relatively self-contained phrase. Sometimes picking alternative words or structures will do it, and sometimes re-ordering the sentence is best. For example, your first sentence could be:
They talked with a gun about the boy from the countryside.
They talked about the boy from the countryside, who had a gun.
They talked about the boy, who had a gun from the countryside.
Your second sentence could be parsed as "the (world of turmoil) (in China)", where whatever turmoil is very significant, as in the idiom world of hurt. It could also be parsed as "the world (of turmoil in China)". Any rephrase to clarify to that would likely be wordy, but it's likely that context around the sentence will be able to make it clear.