A Lagrangian formalism is used to compute the onset of linear instability in magnetic heterostructures subject to two competing dissipative phenomena: the intrinsic damping and the current-induced spin-transfer-torque. The small-amplitude precessional dynamics undergone by the magnetization vector at the excitation threshold is described in terms of linearized Lagrange equations which are recast as a complex generalized non-Hermitian eigenvalue problem. The numerical solution of such a problem allows to characterize those magnetic normal modes which become unstable when the “negative” losses induced by the electric current fully compensate the intrinsic “positive” ones. An illustrative example is also carried out in order to test the capability of the proposed method to determine accurately such an instability threshold when geometric or material properties are varied.