The following example runs for me in 2018.1:
from dolfin import *
mesh = UnitSquareMesh(10,10)
V = FunctionSpace(mesh,"Lagrange",1)
u = Function(V)
v = TestFunction(V)
x = SpatialCoordinate(mesh)
f = x[0]*x[1]
res = (1.0+u*u)*inner(grad(u),grad(v))*dx + inner(u,v)*dx - inner(f,v)*dx
Dres = derivative(res,u)
class CustomNonlinearProblem(NonlinearProblem):
def F(self,b,x):
return assemble(res,tensor=b)
def J(self,A,x):
return assemble(Dres,tensor=A)
problem = CustomNonlinearProblem()
solver = PETScSNESSolver()
solver.solve(problem,u.vector())
I can also set the options
solver.parameters['linear_solver'] = 'lu'
solver.parameters['report'] = False
before solving without any errors.