Thanks for your answers. I think it makes more sense now. What troubles me is that I have a 1d constant charge distribution in a program, where I am working with everything numerically. And if I invert the discrete operator ∇2 to get the potential as -[∇2]-1ρ/ε0, which is well defined even inside the charge distribution. Why does it not diverge like in the analytical calculation?
So moving on:
Suppose I now have some rectangular box containing a homogenous charge distribution with density ρ0. Then the solution to Poissons equation is that I should calculate the integral:
V(r) = ρ0/4πε0 ∫dr 1/lr-r'l
Is this integral solvable or divergent?
Either way my end goal is to look at what the stable charge distribution is for a rectangular box. I.e. which distribution of charge inside the box will minimize the energy. Is it possible to solve this problem using variational calculus or something like that?