Ratio distribution of continous uniform Let $X, Y$ be positive random variables with densities $f_X=\mathbb{I}_{[0, 1]}$ and $f_Y=f_X*f_X$. To find the density of $Y$  we observe that when $0\le y\le 1$ we have $f_Y(y)=y$ and when $1< y\le 2$ then $f_Y(y)=2-y$.
Now if $S=X+Y$ and $R={X\over S}$ I want to find $f_R(r)$.
By the change of variables we get:
$$f_{R,S}(r,s)=sf_X(rs)f_Y(s(1-r))$$
$$f_{R,S}(r,s)=\begin{cases}
s^2(1-r)\mathbb{I}_{0\le s\le {1\over r}}\ \mathbb{I}_{0\le s\le {1\over 1-r}}
\\
(2s-s^2(1-r))\mathbb{I}_{0\le s\le {1\over r}}\ \mathbb{I}_{{1\over 1-r}< s\le {2\over 1-r}}
\end{cases}$$
Now we want to integrate w.r.t $s$. 
For the first case when $0\le r\le {1\over 2}$ then $0\le s\le {1\over 1-r}$ and 
when ${1\over 2}<r\le1$ then $0\le s\le {1\over r}$
For the second case when $0\le r \le{1\over 3}$ then ${1\over 1-r}\le s\le {2\over 1-r}$ and when ${1\over 3}<r \le{1\over 2}$ then ${1\over 1-r}\le s\le {1\over r}$. which gives:
$$f_R(r)=\begin{cases}
{1\over 3(1-r)^2}\ \mathbb{I}_{0\le r\le {1\over 2}}
\\
{1-r\over 3r^3}\ \mathbb{I}_{{1\over 2}< r \le 1}
\\
{2\over 3(1-r)^2} \mathbb{I}_{0\le r \le {1\over 3}}
\\
{2r^3-9r^2+6r-1\over 3r^3(1-r)^2}\mathbb{I}_{{1\over 3}< r \le {1\over 2}}
\end{cases}$$
But this is not a density function. Where did I go wrong?

The joint density of $R, S$ is correct. 
Obviously the support of $R$ is $[0, 1]$. According to the support of the joint, you should split this support into the following $3$ intervals, to facilitate your calculation:
$$ \left(0, \frac {1} {3}\right), \left(\frac {1} {3}, \frac {1} {2}\right), \left(\frac {1} {2}, 1\right)$$
So when $\displaystyle r \in \left(0, \frac {1} {3}\right)$,
$$ \begin{align} 
f_R(r) &= \int_0^{1/(1-r)} s^2(1-r)ds + \int_{1/(1-r)}^{2/(1-r)}2s-s^2(1-r)ds 
= \frac {1} {(1 - r)^2}
\end{align}$$
When $\displaystyle r \in \left(\frac {1} {3}, \frac {1} {2}\right)$,
$$ \begin{align} 
f_R(r) &= \int_0^{1/(1-r)} s^2(1-r)ds + \int_{1/(1-r)}^{1/r}2s-s^2(1-r)ds 
= \frac {3r^3 - 9r^2 + 6r - 1 } {3r^3(1 - r)^2}
\end{align}$$
When $\displaystyle r \in \left(\frac {1} {2}, 1\right)$,
$$ \begin{align} 
f_R(r) &= \int_0^{1/r} s^2(1-r)ds + 0
= \frac {1-r} {3r^3}
\end{align}$$
Note that the second integral vanish as $1/r < 1/(1-r)$ in this case.
You may further check that
$$ \int_0^1 f_R(r)dr = \frac {1} {2} + \frac {1} {3} + \frac {1} {6} = 1 $$
and it is positive over its support. So it is a valid pdf candidate.
