Running tests with xvfb-run

Hello,

PROBLEM:

I’m trying to run VTK testing through xvfb-run ctest and many of the tests (complete list of failed tests) end up failing with ***Exception: Numerical errors.

I’ve been digging into the problem and found that most (probably all) cases follow the same pattern:

Program terminated with signal SIGFPE, Arithmetic exception.
#0  0x00007f333676a376 in lp_build_tgsi_info (tokens=<optimized out>, info=0x564c4e7ddd60)
    at ../mesa-21.2.6/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c:592
b592	                  if (value < 0.0f || value > 1.0f) {
[Current thread is 1 (Thread 0x7f3337144fc0 (LWP 171475))]
(gdb) backtrace
#0  0x00007f333676a376 in lp_build_tgsi_info (tokens=<optimized out>, info=0x564c4e7ddd60)
    at ../mesa-21.2.6/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c:592
[...]
#15 0x00007f3337009320 in glXCreateContextAttribsARB (dpy=0x564c4e83a4d0, config=0x564c4e8768b0,
    share_context=0x0, direct=1, attrib_list=0x7ffc552f2560) at ../mesa-21.2.6/src/glx/create_context.c:100
#16 0x00007f333d895d4f in glXCreateContextAttribsARB (dpy=0x564c4e83a4d0, config=0x564c4e8768b0, share_list=0x0,
    direct=1, attrib_list=0x7ffc552f2560) at ../libglvnd-v1.3.4/src/GLX/libglx.c:305
#17 0x00007f333e526efc in vtkXOpenGLRenderWindow::CreateAWindow (this=0x564c4e71c2d0)

On window creation code in mesa raises a SIGFPE (complete backtrace). Researching a little more on the issue I found a related issue in the mesa project stating that:

it’s a really bad idea calling into mesa code with changed fpe environment so that signalling NaNs get triggered (this can easily hit crashes in other places as well). The real fix would be to change the calling code (wherever the fpe env change comes from) to not do that.

PROPOSED SOLUTION:

Based on the aforementioned mesa issue I have found that a call to vtkFloatingPointExceptions::Disable() before creation of render windows, does not trigger the errors and make the tests pass. Furthermore, some tests seem to already include vtkFloatingPointExceptions::Disable() (e.g., TestGPURayCastIsosurface.cxx:22) maybe for similar reasons.

If this would be an acceptable approach I could prepare a PR for this.

I suspect that more tests need DISABLE_FLOATING_POINT_EXCEPTIONS passed into the test declarations. See existing usage in Rendering/RayTracing/Testing/Cxx/CMakeLists.txt for how to apply it to a test.

Thank you @ben.boeckel for the quick reply. Here is a PR addressing this issue: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8799