This problem arises from the following property of Dirac $\delta-$function: $$\delta(f(x))=\sum_{a_i\in Z(f)}\frac{\delta(x-a_i)}{|\frac{df}{dx}(a_i)|} $$ where $Z(f):=\{x\in dom(f)|\,f(x)=0\}$, the zero-set of $f$.
Here, many people use the Taylor expansion of $f(x)$ to prove the property. Specifically, they expand $f(x)$ around those zero point of $f$, for example, $f(x)=f(a_i)+f'(a_i)(x-a_i)+\mathcal{O}((x-a_i)^2)$, where $f(a_i)=0$, and say that $\mathcal{O}((x-a_i)^2)$ is higher order infinitesimal to $(x-a_i)$ therefore they are neglegible, which sounds reasonable.
However, when $f(x)$ is the power of $x$, for example, $f(x)=x^2$. Then the above form tell us $\delta(x^2)=\frac{\delta(x-0)}{2\cdot0}$ which is ill-defined. Similarly to $x^n$.
One may define the extended version such that $\frac{1}{0}:=\infty$, then the whole $\delta(x^2)$ still make sense. However, if one tries to evaluate the following integral:
$$\int_{-\infty}^{\infty}x\delta(x^2)dx $$ by the above formula, it will give us $$\int_{-\infty}^{\infty}x\delta(x^2)dx=\int_{-\infty}^{\infty}x\frac{\delta(x)}{2\cdot 0}dx=\frac{0}{2\cdot 0} $$ which is an ill-defined result.
On the other hand, notice $xdx=\frac{1}{2}d(x^2)$
$$\int_{-\infty}^{\infty}x\delta(x^2)dx=\frac{1}{2}\int_{-\infty}^{\infty}\delta(x^2)d(x^2)=\frac{1}{2}$$ which I think this is just a coincidence. (the reason is one can have the integrand to be $x^3\delta(x^2)$, again use $xdx=\frac{1}{2}d(x^2)$, this time the first way generate the same wield formula, while the second way gives you $0$).
Can anyone explain it to me? (Notice, whenever the denominator is not zero, everything looks fine)