Hi OpenFHE team!
I met a bug about CryptoContext setting(In bfv,bgv,ckks schme). I accidentally setting the CryptoContext to nullptr. and I turn on the features(LevelSHE etc). it pop up a segmentation fault. So I think there are should be checking before you let the features enable to use.
Here is the MWE:
int main(int argc, char* argv[]) {
uint32_t multDepth = 1;
uint32_t scaleModSize = 50;
CCParams<CryptoContextBGVRNS> parameters;
parameters.SetPlaintextModulus(256);
parameters.SetMultiplicativeDepth(multDepth);
parameters.SetScalingModSize(scaleModSize);
parameters.SetScalingTechnique(FIXEDMANUAL);
parameters.SetFirstModSize(60);
CryptoContext<DCRTPoly> cc = nullptr;
std::string version = GetOPENFHEVersion();
std::cout << "OpenFHE version: " << version << std::endl;
std::cout << parameters << std::endl;
cc->Enable(PKE);
cc->Enable(LEVELEDSHE);
cc->Enable(KEYSWITCH);
cc->Enable(ADVANCEDSHE);
}
Output:
OpenFHE version: 1.2.1
scheme: CKKSRNS; ptModulus: 256; digitSize: 0; standardDeviation: 3.19; secretKeyDist: UNIFORM_TERNARY; maxRelinSkDeg: 2; ksTech: HYBRID; scalTech: FIXEDMANUAL; batchSize: 0; firstModSize: 60; numLargeDigits: 0; multiplicativeDepth:1; scalingModSize: 50; securityLevel: HEStd_128_classic; ringDim: 0; evalAddCount: 0; keySwitchCount: 0; encryptionTechnique: STANDARD; multiplicationTechnique: HPS; multiHopModSize: 0; PREMode: INDCPA; multipartyMode: FIXED_NOISE_MULTIPARTY; executionMode: EXEC_EVALUATION; decryptionNoiseMode: FIXED_NOISE_DECRYPT; noiseEstimate: 0; desiredPrecision: 25; statisticalSecurity: 30; numAdversarialQueries: 1; ThresholdNumOfParties: 1
Segmentation fault
Asan(AddressSanitizer is a powerful memory error detection utility) Output:
AddressSanitizer:DEADLYSIGNAL
=================================================================
==4040634==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000018 (pc 0x000000405617 bp 0x0fffda49b5a8 sp 0x7ffed24dad40 T0)
==4040634==The signal is caused by a READ memory access.
==4040634==Hint: address points to the zero page.
#0 0x405616 (/data/homomorphic/test-openfhe/new-build/bug+0x405616)
#1 0x7fa39d232082 (/lib/x86_64-linux-gnu/libc.so.6+0x24082)
#2 0x4059ed (/data/homomorphic/test-openfhe/new-build/bug+0x4059ed)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/data/homomorphic/test-openfhe/new-build/bug+0x405616)
Is this a bug?
I would really appreciate any insights or explanations regarding this behavior.
Thank you for your help!
Best regards,
wowblk