I think srsa's suggestion of testing MoveFocusLensToDistance directly in aflock and mf without calling set_focus has merit. While I don't see any way our code would cause the observed symptoms, there's definitely room for some bugs.
Capturing some discussion from IRC (edited for relevance)
< waterwingz> well, that answers one question ... bork mode is possible from a cold power up using only set_mf() ... and it "seems" to be easier to get into bork mode when the script first sets the zoom position (there's a scripted 3 second delay after it does that)
< waterwingz> somehow the meteor2.lua v2.3 script seem to hit it more than my various test scripts ... and once I edit luascript.c to use SET_LATER it runs correctly all the time ...
< reyalp> I don't think a blanket set_later is the correct solution since the old mf cams have been using set_now since forever and some crash
though a crash is easier to detect than an intermittent failure I guess
the crashy ones are going to need their own define or something too
Also, related to focus overrides in general:
< reyalp> while ((shooting_is_flash_ready()!=1) || (focus_busy)) msleep(10);
wtf is flash_ready doing in there...
< waterwingz> I had assumed it did not want to fire while still charging ?
< reyalp> sure, but what the hell is it doing in the focus override code?
also, that would impact set_now...
because you definitely don't need to wait for flash in that case
there's the stuff with conf.dof_subj_dist_as_near_limit and conf.dof_use_exif_subj_dist
which I have no idea what is supposed to be doing or what the defaults are