quiet / QuietModemKit

iOS framework for the Quiet Modem (data over sound)
BSD 3-Clause "New" or "Revised" License
451 stars 50 forks source link

Crash on iPhone #23

Open chanduthedev opened 5 years ago

chanduthedev commented 5 years ago

Hi Brian, I can able to transfer data using Quiet framework in iOS. But consistently app is crashing in iOS due to below error message. I think this is related incorrect memory access. But I didn't do any code changes related to memory issue. Can you please help on this? You can find the code if required https://github.com/chanduthedev/iOS/tree/master/QuietShare

Error log:

2019-05-06 11:39:28.695414+0800 TestSoundPayment[745:112219] In receive profile :ultrasonic-experimental TestSoundPayment(745,0x104cfebc0) malloc: Incorrect checksum for freed object 0x10581f000: probably modified after being freed. Corrupt value: 0x0 TestSoundPayment(745,0x104cfebc0) malloc: *** set a breakpoint in malloc_error_break to debug (lldb)

Crash backtrace:

Screenshot 2019-05-06 at 11 41 25 AM
brian-armstrong commented 5 years ago

Hi,

Are you sure that your repo contains the most recent version of your code? Your stacktrace references lines/functions that don't seem to exist.

chanduthedev commented 5 years ago

HI Brian, Thanks for quick reply. Yes backtrace is from that repo only. Please check another latest backtrace below which is also taken from same repo, but some UI changes in storyboard. I hope UI changes wont effect this crash.

Crash logs:

2019-05-06 17:47:48.714653+0800 QuietShare[1094:179918] granted is 1 QuietShare(1094,0x1024fabc0) malloc: Incorrect checksum for freed object 0x120869000: probably modified after being freed. Corrupt value: 0x0 QuietShare(1094,0x1024fabc0) malloc: *** set a breakpoint in malloc_error_break to debug (lldb) bt QuietModemKit was compiled with optimization - stepping may behave oddly; variables may not be available. warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.

Crash backtrace:

image
brian-armstrong commented 5 years ago

Unfortunately I don'trealy have time to look into this right now. I believe the tests in QuietModemKit do try to test that dealloc works though. Can you verify whether the tests pass for you, and if so, can you try to modify them to reproduce the behavior you're seeing here? If I do get some time for this, it will be much easier for me look into it inside the tests.

chanduthedev commented 5 years ago

Thanks for the suggestion @brian-armstrong . I will try to run test cases and update if I face any issues. Thanks again for the prompt response.

chanduthedev commented 5 years ago

Hi @brian-armstrong , I am getting below error while building QuietModemKit in xcode. Please let me know id I need to do any settings in xcode. I can able to build successfully using 'carthage update'

Error message:

does not appear to contain CMakeLists.txt.

image
chanduthedev commented 5 years ago

Hi @brian-armstrong I can able to resolve some of the dependency issues while building QuietModemKit binary for running tests cases in xcode and I struck with below error. Can you please check if you can help on this error.

image
brian-armstrong commented 5 years ago

It looks like you're missing the submodules. You might need to do something like git submodule update --init --recursive

chanduthedev commented 5 years ago

thanks very much @brian-armstrong . Actually I installed all sub modules manually, after submodules installation I tried to build, then only I got this error.

chanduthedev commented 5 years ago

I cloned in a separate folder and did git submodule update --init --recursive. Now I can able to build successfully and able to run the test cases. thanks @brian-armstrong. Now I will try to modify test cases to reproduce my scenario in test cases.

chanduthedev commented 5 years ago

Hi @brian-armstrong I tried with test cases and no crash issue occurred. Let me explain my scenario, so that you will get better understanding of the crash.

My app has three buttons as below.

  1. Receive (to receive data, listening mode)
  2. Send (To send data, sending mode)
  3. Cancel (Cancelling the send mode)

Scenario 1 (No crash):

If I use CFRunLoopRun() in sending/receive mode , crash is not happening. But once started, we cant stop sending/receiving mode in this scenario.

Scenario 2 (Crash issue):

To have more control on sending/receive mode, I added timer instead of CFRunLoopRun(). In this case crash is happening. 1. Receive: When click on this button, I am calling setblocking method for 10 secs. So app will be in listening mode for 10 secs and stops after 10 sec if no data is received or stops whenever data received. 2. Send: When click on this button, Timer will start for 1sec and ultrasonic-experimental profile sound will be generated for every sec until cancel button clicked. 3. Cancel : This will stop the timer for sending data.

Below are the steps to reproduce crash issue:

  1. Click on receive button, (button will be disabled until data received or for 10secs)
  2. send data from other device
  3. Repeat from step1

My Analyses:

can you please help on this?

Thanks again for your support.

brian-armstrong commented 5 years ago

I haven't had a chance to try any of the code myself, but one thing that looks suspicious here is setting a receive callback and calling receive. I don't think that would cause a crash, but it probably won't give you predictable behavior. If you specify a callback then QMKit assumes you won't call receive yourself.

chanduthedev commented 5 years ago

I removed setReceiveCallback method and tried again, still facing crash issue.

chanduthedev commented 5 years ago

Hi @brian-armstrong I tried using CFRunLoopRun();, in this case there is no crash issue. But when I use setBlocking method, I face crash consistently. Below code may help to find the root cause.

No Crash occurring Code :

` -(IBAction)clickMe:(id)sender { [[AVAudioSession sharedInstance] requestRecordPermission:request_callback];

CFRunLoopRun();
if (rx != nil) {
    [rx close];
}

} `

Crash occurring code:

`

[[AVAudioSession sharedInstance] requestRecordPermission:request_callback];

[rx setBlocking:10 withNano:0];
if (rx != nil) {
    NSData *recvd = [[rx receive] copy];
    NSString *temp = [NSString stringWithFormat:@"%s", [recvd bytes]];
    [rx close];
    NSLog(@"rx value is  %@", temp);
}

`

Thanks in advance.