Last night I forgot to charge my HTC One M8 phone, and when I woke up in the morning, the battery was dead, Unsurprisingly. I plugged it in to charge for about 20 minutes (only to about 30% or so charge) and then left my house (with my phone in my pocket). The device was off during charging, and I only turned it on about an hour ago, putting it back in my pocket after seeing that it booted fine (and that I had about 30% charge left). About 15 minutes ago, I noticed the device against my leg getting very hot, and pulled it out to see the "HTC One" startup screen. I found this strange because I had already turned on the device, so I don't know why it would be rebooting.
After it started up again, I went looking for what may have caused my phone to seemingly reboot as it did, and in the process of using the device to do this, my screen went black and showed the HTC startup screen again, and afterward, back to my lock-screen. I'm pretty sure It's been doing this cycle of starting up and then randomly rebooting since I turned the unit on some hour ago.
I use an OtterBox Defender case on my phone, and noticing that it was extremely hot on its own, I removed the phone from its case. The rear of the phone was even hotter, to say that I wouldn't be able to hold the device that long because of how warm it is. From this, I was able to determine that overheating could be the cause of this cycle, so I tried to shut off the device by holding the power button and selecting "Power off" from the menu, but after it would shut down, the unit would turn back on. I have no explanation for how or why this would happen.
It seems now the device has run itself out of battery, so I'm letting it cool for the next couple hours until I can charge it again at home. Is there any solution to this should it be happening again?
Stock Android 5 Lollipop, Sense 6.0, No S-Off or Root