element-hq / element-hq/element-ios

Application crashing because NSException not handled

Open
#7,464 2 comments 0 reactions 0 assignees View on GitHub
A-SDK O-Uncommon S-Critical T-Defect
Dominant language
Swift
Stars
1.8k
Forks
544
PR merge metrics
PR metrics pending

Description

In class `MatrixSDK/Core/MXKeyProvider`, the method `- (nonnull MXKeyData *)keyDataForDataOfType:(NSString *)dataType` raise Excpetion that doesn't seem to be always catched:
```
- (nonnull MXKeyData *)keyDataForDataOfType:(NSString *)dataType
isMandatory:(BOOL)isMandatory
expectedKeyType:(MXKeyType)keyType
{
MXKeyData *keyData = [self.delegate keyDataForDataOfType:dataType];

if (!keyData && isMandatory)
{
[NSException raise:@"MandatoryKey" format:@"No key value for mandatory Key (data type : %@)", dataType];
}

if (keyData && keyData.type != keyType)
{
[NSException raise:@"KeyType" format:@"Wrong key type (%lu expected %lu) for data of type : %@", keyData.type, keyType, dataType];
}

return keyData;
}
```

I think it causes crash when exiting application from background state.

### Operating system version

iOS 16.3.1

### Application version

Element Rebase 1.10.4

### Homeserver

Tchap HomeServer

### Will you send logs?

No

Contributor guide

Open the contributing guide

Research direction

Start by reading MatrixSDK/Core/MXKeyProvider and tracing calls to keyDataForDataOfType:isMandatory:expectedKeyType:, especially during application exit from the background state. Reproduce or inspect the reported NSException path and verify that the background-exit crash is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, objective-c
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.