It's really just a theoretical problem at this point. There is still more than enough active investing going on to perform price discovery.
My own theory is that if and when too many people have moved over to indexing then, yes, they will get the market return, but a) that market return will generally be lower than we have seen in the past, and b) it will also be much easier to beat the market... and the issue becomes self-correcting. Generally with markets, if too many people do one thing that "works" it then eventually stops working. It may be that in a world of too many indexers, just being able to identify good cheap companies from bad expensive ones may be enough of an edge to beat the market overall (provided you hold for a long enough period) which will entice people will move back to active investing, and so the market itself finds the right balance between indexers and active investors.
Of course, the data at this point is always backward looking. We know a dismally small number of active funds beat the market in the last 10 years, but going forward as this has enticed more people to indexing, it remains to be seen how that number is continually changing. I don't expect in a world where most people index that a plurality of funds can beat or match or the market, but I do expect that it would be a higher number than we see currently.
The saying with passive investing is that "dumb money stops becoming dumb when it recognises its own limitations". But I would add that it at some point it probably becomes dumb money thinking its being clever but is actually back to being dumb money when everyone is doing it.