I have encountered a bug in _mesa_update_framebuffer_visual when DEFAULT_SOFTWARE_DEPTH_BITS is set to 31.  This has been there since 6.4.2.  In that function, the fb->Visual.depthBits is getting reset to 32, and then compute_depth_max is setting fb->_DepthMax to some undefined value.  This only happens when I use osmesa, and results in depth buffering artifacts in the resulting hardcopy.  I'm not sure why the value is getting reset from 31 to 32, but can anyone suggest a better fix than

   if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
      fb->Visual.haveDepthBuffer = GL_TRUE;
         = fb->Attachment[BUFFER_DEPTH].Renderbuffer->DepthBits - 1;