Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault During PIRProcessDatabase Execution #34

Open
alexlin-gogolook opened this issue Sep 30, 2024 · 2 comments
Open

Segmentation Fault During PIRProcessDatabase Execution #34

alexlin-gogolook opened this issue Sep 30, 2024 · 2 comments

Comments

@alexlin-gogolook
Copy link

alexlin-gogolook commented Sep 30, 2024

Environment

  • macOS 15.0
  • Xcode 16.0
  • SwiftProtobuf 1.28.1

Description

I followed the steps outlined in the TestingInstructions.md. When I executed the command:

ConstructDatabase --icon-directory icons input.txtpb block.binpb identity.binpb

I encountered an error. It seems that there is an EXC_BAD_ACCESS happening on line 61 of ConstructDatabase.swift at the call to example.textFormatString().

To troubleshoot, I commented out the exampleIdentities and directly initialized inputIdentities instead of decoding it from textFormatString. After this change, I was able to generate block.binpb and identity.binpb.

However, when I followed the instructions further and executed:

PIRProcessDatabase block-config.json

I encountered the following error:

2024-09-30T18:03:26+0800 info PIRProcessDatabase : [PIRProcessDatabase] Processing database with configuration: {
  "algorithm" : "mulPir",
  "cuckooTableConfig" : {
    "bucketCount" : {
      "allowExpansion" : {
        "expansionFactor" : 1.1,
        "targetLoadFactor" : 0.9
      }
    },
    "hashFunctionCount" : 2,
    "maxEvictionCount" : 100,
    "maxSerializedBucketSize" : 1024,
    "multipleTables" : true,
    "slotCount" : 255
  },
  "inputDatabase" : "block.binpb",
  "keyCompression" : "noCompression",
  "outputDatabase" : "block-SHARD_ID.bin",
  "outputPirParameters" : "block-SHARD_ID.params.txtpb",
  "rlweParameters" : "n_4096_logq_27_28_28_logt_5",
  "sharding" : {
    "entryCountPerShard" : 1000
  },
  "trialsPerShard" : 5,
  "useMaxSerializedBucketSize" : false
}
2024-09-30T18:03:26+0800 info PIRProcessDatabase : [PIRProcessDatabase] Sharded database into 1 shards
2024-09-30T18:03:26+0800 info PIRProcessDatabase : [PIRProcessDatabase] Processing shard 0 with 3 rows
2024-09-30T18:03:26+0800 info PIRProcessDatabase : [PIRProcessDatabase] Created cuckoo table CuckooTableInformation(entryCount: 3, bucketCount: 2, emptyBucketCount: 1, loadFactor: 0.017089844)
2024-09-30T18:03:26+0800 info PIRProcessDatabase : [PIRProcessDatabase] Validating shard 0
zsh: segmentation fault  PIRProcessDatabase block-config.json

Any insight into what might be causing the segmentation fault or the initial EXC_BAD_ACCESS would be greatly appreciated!

@fboemer
Copy link
Contributor

fboemer commented Sep 30, 2024

Any insight into what might be causing the segmentation fault or the initial EXC_BAD_ACCESS would be greatly appreciated!

Can you run this command with lldb? I.e., run

lldb PIRProcessDatabase block-config.json

Then, in the (lldb) prompt, enter run,

(lldb) run

Hopefully, you'll see the crash, and be able to enter backtrace.

(lldb) backtrace

which will return a backtrace of the issue.
If you can post the backtrace here, this will help us diagnose what the issue is.

@alexlin-gogolook
Copy link
Author

Thank you for your reply.

Backtrace:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
  * frame #0: 0x000000019473975c libswiftCore.dylib`swift_getAssociatedTypeWitness + 28
    frame #1: 0x000000010025bd44 PIRProcessDatabase`BinaryEncodingSizeVisitor.visitMapField<SwiftProtobuf.ProtobufUInt64, HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_SerializedKeySwitchKey>(fieldType=SwiftProtobuf._ProtobufMessageMap<τ_0_0, τ_0_1>, value=Swift.Dictionary<Swift.UInt64, HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_SerializedKeySwitchKey> @ 0x0000000115e04300, fieldNumber=1) at <stdin>:0 [opt]
    frame #2: 0x000000010025ca38 PIRProcessDatabase`protocol witness for Visitor.visitMapField<A, B>(fieldType:value:fieldNumber:) in conformance BinaryEncodingSizeVisitor at <compiler-generated>:0 [opt]
    frame #3: 0x000000010017cb24 PIRProcessDatabase`Apple_SwiftHomomorphicEncryption_V1_SerializedGaloisKey.traverse<SwiftProtobuf.BinaryEncodingSizeVisitor>(visitor=(serializedSize = 0)) at apple_swift_homomorphic_encryption_v1_he.pb.swift:694:19 [opt]
    frame #4: 0x000000010017cd50 PIRProcessDatabase`protocol witness for Message.traverse<A>(visitor:) in conformance Apple_SwiftHomomorphicEncryption_V1_SerializedGaloisKey at <compiler-generated>:0 [opt]
    frame #5: 0x000000010028cabc PIRProcessDatabase`Message.serializedDataSize() at Message+BinaryAdditions.swift:74:9 [opt]
    frame #6: 0x000000010025a550 PIRProcessDatabase`BinaryEncodingSizeVisitor.visitSingularMessageField<τ_0_0>(value=<unavailable>, fieldNumber=<unavailable>) at BinaryEncodingSizeVisitor.swift:351:33 [opt]
    frame #7: 0x000000010025c768 PIRProcessDatabase`protocol witness for Visitor.visitSingularMessageField<A>(value:fieldNumber:) in conformance BinaryEncodingSizeVisitor at <compiler-generated>:0 [opt]
    frame #8: 0x000000010017e0fc PIRProcessDatabase`closure #1 in Apple_SwiftHomomorphicEncryption_V1_SerializedEvaluationKey.traverse<SwiftProtobuf.BinaryEncodingSizeVisitor>(, visitor=(serializedSize = 0)) at apple_swift_homomorphic_encryption_v1_he.pb.swift:800:19 [opt]
    frame #9: 0x000000010017e028 PIRProcessDatabase`Apple_SwiftHomomorphicEncryption_V1_SerializedEvaluationKey.traverse<SwiftProtobuf.BinaryEncodingSizeVisitor>(visitor=(serializedSize = 0)) at apple_swift_homomorphic_encryption_v1_he.pb.swift:799:9 [opt]
    frame #10: 0x000000010017e354 PIRProcessDatabase`protocol witness for Message.traverse<A>(visitor:) in conformance Apple_SwiftHomomorphicEncryption_V1_SerializedEvaluationKey at <compiler-generated>:0 [opt]
    frame #11: 0x000000010028c810 PIRProcessDatabase`Message.serializedBytes<HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_SerializedEvaluationKey>(partial:options:) at Message+BinaryAdditions.swift:74:9 [opt]
    frame #12: 0x000000010028c7e0 PIRProcessDatabase`Message.serializedBytes<HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_SerializedEvaluationKey>(partial=<unavailable>, options=(useDeterministicOrdering = false)) at Message+BinaryAdditions.swift:41:28 [opt]
    frame #13: 0x0000000100217b08 PIRProcessDatabase`EvaluationKey.size() [inlined] generic specialization <HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_SerializedEvaluationKey> of SwiftProtobuf.Message.serializedData(partial: Swift.Bool) throws -> Foundation.Data at <compiler-generated>:0 [opt]
    frame #14: 0x0000000100217ab8 PIRProcessDatabase`EvaluationKey.size() at ConversionPir.swift:230:33 [opt]
    frame #15: 0x00000001001a0fbc PIRProcessDatabase`merged generic specialization <HomomorphicEncryption.Bfv<Swift.UInt64>> of PrivateInformationRetrieval.ProcessKeywordDatabase.ShardValidationResult.description() throws -> Swift.String + 504
    frame #16: 0x000000010019d764 PIRProcessDatabase`specialized ProcessDatabase.process<A>(config=<unavailable>) at ProcessDatabase.swift:386:57 [opt]
    frame #17: 0x00000001001a2cd0 PIRProcessDatabase`ProcessDatabase.run() at ProcessDatabase.swift:419:17 [opt]
    frame #18: 0x00000001001a2f98 PIRProcessDatabase`protocol witness for ParsableCommand.run() in conformance ProcessDatabase at <compiler-generated>:0 [opt]
    frame #19: 0x00000001001da6c8 PIRProcessDatabase`specialized static ProcessDatabase.$main() [inlined] generic specialization <PIRProcessDatabase.ProcessDatabase> of static ArgumentParser.ParsableCommand.main(Swift.Optional<Swift.Array<Swift.String>>) -> () at <compiler-generated>:0 [opt]
    frame #20: 0x00000001001da67c PIRProcessDatabase`specialized static ProcessDatabase.$main() [inlined] generic specialization <PIRProcessDatabase.ProcessDatabase> of static ArgumentParser.ParsableCommand.main() -> () at <compiler-generated>:0 [opt]
    frame #21: 0x00000001001da67c PIRProcessDatabase`specialized static ProcessDatabase.$main() at <compiler-generated>:299:1 [opt]
    frame #22: 0x00000001001a3140 PIRProcessDatabase`PIRProcessDatabase_main [inlined] static PIRProcessDatabase.ProcessDatabase.$main() -> () at ProcessDatabase.swift:0 [opt]
    frame #23: 0x00000001001a313c PIRProcessDatabase`PIRProcessDatabase_main at ProcessDatabase.swift:0 [opt]
    frame #24: 0x00000001833bc274 dyld`start + 2840

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants