What is wrong with the following u-substitution? We will calculate $\displaystyle\int^{2 \pi}_0 x \, dx$.  Let $u=\sin (x)$, and observe that $\sin(2 \pi)=0$ and $\sin(0)=0$.  We also have that $\frac{du}{dx}=\cos(x)=\sqrt{1-u^2}$. Hence,
$$
\int^{2 \pi}_0 x \, dx=\int^0_0 \frac{\sin^{-1}(u)}{\sqrt{1-u^2}} \, du = 0.
$$
This is very obviously wrong, but I am not sure how to explain the error formally.

Edit:
Thanks for the responses and in particular the link below to the related problem!  The error is indeed caused by the substitution $x=\sin^{-1}(u)$.  The integration is performed over $[0,2 \pi]$ which is outside the range of the $\sin^{-1}$ function.  

Remark
The error is slightly better disguised when calculating $\displaystyle\int^1_{-1}\frac{2x}{1+x^2} \, dx.$

Let $u(x)=1+x^2$, and observe that $u(1)=u(-1)=2$.  Then since $dx=\frac{1}{2x} du$, we have that
$$
\int^1_{-1} \frac{2x}{1+x^2} \, dx =  \int^2_2 \frac{1}{u} \, du=0.
$$
This time, no trigonometric substitution is used, but it is still an incorrect proof for the same reason as above.  A correct proof can be obtained by using the fact that $x \mapsto \displaystyle\frac{2x}{1+x^2}$ is odd.

This example is more disturbing because the procedures above are entirely intuitive and yield the correct result. It seems to me that students when taught integration by substitution of definite integrals should also be taught that great care be exercised in checking the range of integration, particularly when the (apparent) substituting function is not invertible in that range.
Contrary to the OP's Remark/claim, the integration-by-substitution solution provided for the example $\displaystyle\int^1_{-1}\frac{2x}{1+x^2} \, \mathrm{d}x\,$ is actually perfectly valid—and not disturbing—despite the substitution function $u=1+x^2$ not being injective (and certainly not invertible either) on $[-1,1]$: integration by substitution does not intrinsically require the substitution function to be invertible/bijective or monotonic—or even injective—on the interval of integration.
Integration by substitution (change of variable):
If $g'$ is integrable on $[a,b]$ and $f$ is continuous on $g[a,b]$,
then $$\int_a^bf(g(x))g'(x)\mathrm{d}x=\int_{g(a)}^{g(b)}f(u)\mathrm{d}u.$$
In this example: Let $g(x)=1+x^2,\,\,f(u)=\frac1u,\text{ and }\,a=-1,b=1$.
Then $f(g(x))=\frac1{1+x^2},\,\,g'(x)=2x,\text{ and }\,g(a)=g(b)=2$.
The above theorem is validly applicable here
$$\int^1_{-1}\frac{2x}{1+x^2}\,\mathrm{d}x=\int_2^2\frac1u\,
   \mathrm{d}u=0,$$ yet $g(x)$ isn't injective on $[-1,1].$

However, splitting up the original integral such that the
substitution function is injective on each subinterval does
generally prevent the substitution process from running into
&quot;glitches&quot; (due to misapplication of the integration-by-substitution
theorem).
So, for the OP's main example:
Let $u=\sin x\,$ so that $\,\mathrm{d}u=\cos x \,\mathrm{d}x$.
Now, for $x\in[0, \frac{\pi}{2}]$, \begin{align}\cos x &amp;=
   \sqrt{1-u^2},\\x&amp;=\arcsin u;\end{align} for
$x\in[\frac{\pi}{2},\frac{3\pi}{2}]$, \begin{align}\cos x &amp;=
   -\sqrt{1-u^2},\\x&amp;=\pi -\arcsin u;\end{align} for $x\in[\frac{3\pi}{2}, 2\pi]$, \begin{align}\cos x &amp;=
   \sqrt{1-u^2},\\x&amp;=2\pi +\arcsin u.\end{align}
Therefore \begin{align}\int^{2\pi}_0 x
   \,\mathrm{d}x&amp;=\int^\frac{\pi}{2}_0 x \,\mathrm{d}x +
   \int^\frac{3\pi}{2}_\frac{\pi}{2} x \,\mathrm{d}x +
   \int^{2\pi}_\frac{3\pi}{2} x \,\mathrm{d}x\\&amp;=\int^1_0 \frac{\arcsin
   u}{\sqrt{1-u^2}}\,\mathrm{d}u + \int^{-1}_1 \frac{\pi-\arcsin
   u}{-\sqrt{1-u^2}} \,\mathrm{d}u + \int^0_{-1} \frac{2\pi + \arcsin
   u}{\sqrt{1-u^2}} \,\mathrm{d}u\\&amp;=\pi\int^1_{-1}
   \frac{\,\mathrm{d}u}{\sqrt{1-u^2}}+2\pi\int^0_{-1}
   \frac{\,\mathrm{d}u}{\sqrt{1-u^2}}\\&amp;=\pi\bigg[ \arcsin
   u\bigg]_{-1}^1+2\pi \bigg[\arcsin
   u\bigg]_{-1}^0\\&amp;=2\pi^2.\end{align}
It shoud be obvious that the integral must be evaluated in the progressive direction, otherwise some parts of the summation are deducted rather than added. To achieve this, the transformation must be monotonous.