I wonder if I'm running into the same issue, nvidia driver version 260.19.06 and Ubuntu 10.10, two GPU, 4 monitors, individual X sessions.
I hit the issue when unlocking from using the screensaver (which is on random and to show off amongst my Windows running colleagues is typically something pretty and graphics intensive). The cursor flickers between two screens and I end up with X looping with the strace identical to your second example.
I've raised a bug for it but nothing has happened as yet
In my case if I leave it long enough X consumes all memory, the OOM killer then steps in and kills off X, at which point I can log in again.
Your script doesn't trigger it however.