Take a function $f$ whose graph consists of spikes centered at the positive integers that do not overlap, together with portions of the $x$-axis, with the following properties:
- The area bounded by the $n$th spike and the $x$-axis is less than $1\over n$.
- The area of the "squared spike" is greater than ${1\over2n}$.
- Spikes centered at odd positive integers are above the $x$-axis
- Spikes centered at even positive integers are below the $x$-axis.
Then $\int_0^\infty f(x)\, dx$ converges (it can be computed as a convergent alternating series). Now consider $g=f$.
I believe $f(x)=g(x)=\sin(x^2)$ furnishes an example (it has properties similar to the above).