We investigate the failure of the Stone-Weierstrass theorem focusing on the existence of large dimensional vector spaces within the set \(\mathcal {C}(L, \mathbb {K}) {\setminus } \overline{\mathcal {A}}\) , where L is a compact Hausdorff space and \(\mathcal {A}\) is a self-adjoint subalgebra of \(\mathcal {C}(L, \mathbb {K})\) that vanishes nowhere on L but does not necessarily separate the points of L. We address the problem of finding the precise codimension of \(\overline{\mathcal {A}}\) in a broad setting, which allows us to describe the lineability of \(\mathcal {C}(L, \mathbb {K}) {\setminus } \overline{\mathcal {A}}\) in detail. Our analysis yields both affirmative and negative results regarding the lineability of this set. Furthermore, we also study the set \((\mathcal {C}(\partial {D}, \mathbb {C}) {\setminus } \overline{\text {Pol}(\partial {D})}) \cup \{0\}\) , where \(\text {Pol}(\partial {D})\) is the set of all complex polynomials in one variable restricted to the boundary of the unit disk. Recent lineability properties are also taken into account.