According to a post on the RAF Command Forums, both were lost in the crash of the Lancaster SW290 of 224 Sqn or Joint Anti-Submarine School.
See
http://www.rafcommands.com/archive/04371.php
There is more info, including a newspapers article, in the following link:
https://aviation-safety.net/wikibase/wiki.php?id=30737
In 1947, HMS Ferret seems to be mostly an anti-submarine warfare training school so the presence of two of its officers in a Lancaster over a submarine for an exercise is not surprising.