While this is primarily a druid spell combination, the Arcana Cleric, Divine Soul Sorcerer, and Genie Warlock subclasses all have access to both spells as well.
The 3rd-level spell Meld into Stone allows you to remain inside of stone for a lengthy duration of eight hours, does not require concentration, and (emphasis mine):
You step into a stone object or surface large enough to fully contain your body, melding yourself and all the equipment you carry with the stone for the duration…
You remain aware of the passage of time and can cast spells on yourself while merged in the stone. You can use your movement to leave the stone where you entered it, which ends the spell. You otherwise can’t move.
Minor physical damage to the stone doesn’t harm you, but its partial destruction or a change in its shape (to the extent that you no longer fit within it) expels you and deals 6d6 bludgeoning damage to you. The stone’s complete destruction (or transmutation into a different substance) expels you and deals 50 bludgeoning damage to you. If expelled, you fall prone in an unoccupied space closest to where you first entered (PHB, pg 259).
Whereas the 6th-level spell Investiture of Stone lasts for up to ten minutes, requires concentration, and gives the following benefit (among others) until the spell ends:
You can move through solid earth or stone as if it was air and without destabilizing it, but you can’t end your movement there. If you do so, you are ejected to the nearest unoccupied space, this spell ends, and you are stunned until the end of your next turn (XGE, pg 159).
The spell mentions that your movement does not destabilize the stone nor does it actually transmute it to air, which neatly skirts the terminating conditions of Meld into Stone. So it doesn’t seem as if merely moving through stone would expel you and cause you to take the accompanying damage.
So far so good. However, Investiture of Stone states that you cannot end your movement within the stone without being ejected to the nearest unoccupied space and stunned, while Meld into Stone is also explicit in describing that if expelled from the stone you fall prone in an unoccupied space closest to where you first entered.
Let alone trying to decide whether you can remain within the stone, the effects of the two spells are conflicting and determining which would take precedence is unclear.
The crux of the issue, as I see it, is that Meld into Stone allows you to remain within stone at the cost of your movement, while Investiture of Stone allows you to move through stone but not remain within.
While it does not seem as though these spells were intended to be used in conjunction with each other, Investiture of Stone has a range of self and as such is one of the few spells you are allowed to cast while under the effects of Meld into Stone.
How would you reconcile the combined use of these seemingly contradictory spells? Please include how to resolve the effects in event of expulsion from the stone (i.e. fall prone, get stunned, and/or take damage).
Side note: since casting spells on yourself is listed as an acceptable action during Meld into Stone, I’ve gone ahead and assumed that casing Investiture of Stone is permissible regardless of its verbal and somatic components. By all means feel free to address this point if you disagree, but if so please assume the Subtle Spell Metamagic is being used in this scenario as that isn’t the purpose of the question.