Expressions are interpolated into a finite element space before derivatives are evaluated. In particular, if you interpolate into a piecewise linear space all second derivatives will vanish. Considering the following example.
P1 = FiniteElement("Lagrange", triangle, 1)
P2 = FiniteElement("Lagrange", triangle, 2)
f = Expression("x[0]*x[1]", element = P1)
g = Expression("x[0]*x[1]", element = P2)
print assemble(f.dx(0).dx(1) * dx(domain = mesh)) # zero
print assemble(g.dx(0).dx(1) * dx(domain = mesh)) # nonzero
For simple functions of the coordinates, also consider the following alternative approach.
x, y = SpatialCoordinate(mesh)
h = x * y
print assemble(h.dx(0).dx(1) * dx)
This avoids interpolation into FEM space. Instead, the function is evaluated directly in the quadrature points.