I've found that if I use the d2i_AutoPrivateKey_ex API then I can create a valid EVP_PKEY but the EVP_PKEY_get_bn_param() calls to retrieve the P & G values fail.
Here's a modified test to show the failure:
2b76d9b
The EVP_PKEY_get0_DH() and DH_get0_pqg() APIs return the parameters fine but the test fails on the first call to EVP_PKEY_get_bn_param().