jeffmur / fhel

Fully Homomorphic Encryption Library
https://pub.dev/packages/fhel
MIT License
2 stars 0 forks source link

Concurrency > 1 Errors #43

Open jeffmur opened 8 months ago

jeffmur commented 8 months ago

Continued #39 - TLDR: Solution is not scalable. Should only affect dart test --concurrency 16.

Simple Approach: The ErrorTranslator singleton C class stores an error_message that is set in C and read from Dart.

However, when running dart test, the default concurrency is 16. Meaning that at once, we can have up-to 16 instances of Dart Seal objects.

As a result, we may receive intermittent failures when concurrency > 1. This should not affect users as all C FFI calls are synchronous. If there are multiple instances, they would be invoked sequentially.

Potential Solutions:

  1. For each C function, pass Pointer as parameter. This race condition can be solved by creating / managing ErrorTranslator instances for ffi invocation. However this may be overkill.

  2. For each C function, pass string (char*) as parameter: Simple, and a bit more transparent. Would require some additional logic to capture errors + return string. May introduce ambiguous complexity