Sanhedrin8: 7
וְאֵלּוּ הֵן שֶׁמַּצִּילִין אוֹתָן בְּנַפְשָׁן: הָרוֹדֵף אַחַר חֲבֵרוֹ לְהָרְגוֹ, אַחַר הַזְּכוּר, וְאַחַר הַנַּעֲרָה הַמְאֹרָסָה. אֲבָל הָרוֹדֵף אַחַר הַבְּהֵמָה, וְהַמְחַלֵּל אֶת הַשַּׁבָּת, וְהָעוֹבֵד עֲבוֹדָה זָרָה אֵין מַצִּילִין אוֹתָן בְּנַפְשָׁן.
These are those who are saved at the cost of their lives: one who pursues another to kill him, [or who pursues] a male, or a betrothed naarah. However, one who pursues a beast, and one who desecrates the Sabbath, and one who engages in idola-try are not saved at the cost of their lives.