For the source text click/tap here: Gittin 38
To download, click/tap here: PDF
Rav Shemen bar Abba said in the name of Rabbi Yochanan: A Canaanite slave who (was imprisoned after being captured by idolaters) escapes from prison becomes a free man, and not only that, but his master is also forced to write an emancipation document for him.
The Gemora asks from our Mishna: Rabban Shimon ben Gamliel said: It makes no difference what the purpose of the ransom was for; he can anyway be enslaved.
Our daf notes according to Abaye (that the Mishna is referring to a case where the master has not yet given up hope of recovering the slave, there is no difficulty), we can answer that the case of the escaped slave is referring to a master who has given up hope on recovering his slave (and that is why he gains his freedom).
We explore escaped slaves prior to emancipation.