Not prison but I'd say jail was rehabilitating in some ways for me. I went to jail for three days a month after my nineteenth birthday for burglarizing my neighbors while blacked out on Xanax. I detoxed and cried for the entire three days. Some of the "jailhouse lawyers" told me I was likely to get 6 months to a year and I was absolutely terrified. I was headed down a really bad path, I was homeless and suicidal. It was honestly one of the most terrifying and horrible experiences of my life.
I'll never forget crying in my parents arms when I was released. I'm two years sober now and am a student at a university.
P.S. The other convicts in there pranked me on my way out by yelling from their cells that I had to get my mattress stamped on my way out so I carried my mattress all the way to the reception area. The lady there looked at me and said something along the lines of "what the fuck are you doing?"