The method of Lagrange multipliers is used to find the extrema of $f(x)$ subject to the constraints $\vec g(x)=0$, where $x=(x_1,\dots,x_n)$ and $\vec g=(g_1,\dots,g_m)$ for $m \leq n$.
Although many textbooks get the final equations by arguing that at an extrema, the variation of $f(x)$ must be orthogonal to the surface $g(x)=0$, the "simpler" approach (and that which is commonly seen in field theory / optimizing functionals) is to construct the Lagrange function $$ L(x,\lambda) = f(x) + \vec\lambda\cdot\vec g(x) $$ and varying w.r.t. $x$ and $\lambda$ to get the vector equations $$ \begin{align} &x:& 0 &= \nabla f(x) + \sum_i \lambda_i \nabla g_i(x) \,, \\ &\vec \lambda:& 0 &= \vec g(x) \ . \end{align} $$
The method only works if the extremal point is a regular point of the constraint surface, i.e. if $\mathrm{rnk}(\nabla\vec g) = m$.
What is the best way of understanding what goes wrong when the extrema is not a regular point of the constraint?
And, most importantly to me, how does this generalize to field theories (i.e. optimizing functionals) with local constraints? What is the equivalent regularity condition for constraints in field theory?
Instructive examples are more than welcome.