That sounds awful, but it's an emergency when this happens. Therefore, I suggest looking through all the descriptors in your working survey and try to perform an operation on this descriptor, which will cause this error if the descriptor is fictitious. For example, you can create a new temporary poll and try to perform a non-blocking zero timeout poll and see if you can get an error.
If you have more than, say, a dozen descriptors in your survey, you might consider binary search instead of a one-on-one approach. You can add half of your descriptors to a temporary poll, and then perform the operation. If it fails, you know that you have a fake handle in the set that you tried; divide in half and try again; if this does not fail, you can assume that the dummy descriptor is in a different set, and you can either check that the other half fails, or assume that this will happen, and divide the remainder by two and try again. Continue until you isolate one failed descriptor. Clearly, if you have several dummy descriptors, and not just one, you may have to repeat this process several times.
With a single descriptor isolated, you can decide what you need to do and how. And if / when the problem recurs, you can repeat the isolation process. Clearly, you would not try this if you did not find the problem in the first place. But when something goes wrong, you need to isolate the problem, and that (should) have to achieve this.
source share