malloc_error_break error only in background mode (Accelerate framework)

I have an iOS app that uses the accelerate framework to perform an FFT (Fast fourier transform) and a DCT (discrete fourier transform) along with a lot of matrix manipulation. The functions work fine in the foreground but fail in the background with a malloc_error_break error. The error shows in a thread named "Queue: RealtimeMessenger.mServiceQueue(serial)".

Not sure where to start to resolve this issue?

Replies

What does the backtrace from

malloc_error_break
look like?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

In the console, we get:


OneScream-Swift(2223,0x16e0eb000) malloc: *** error for object 0x15600f600: pointer being freed was not allocated

*** set a breakpoint in malloc_error_break to debug


I have taken a screenshot of the crashed app in xcode:


https://www.dropbox.com/s/pogbow3788hy4kv/Screenshot%202017-05-12%2010.41.50.png?dl=0

Right. So if you set a breakpoint on

malloc_error_break
and then reproduce the problem, what do you see in the backtrace?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

HI Eskimo,


The problem was that the CPU usage was too high and this was causing the app to crash. I have slowed down the execution using usleep and this seems to work fine. If there is another way to limit the CPU usage in fucntions, please let me know.


Best,


Feras A.

The problem was that the CPU usage was too high and this was causing the app to crash.

If you’re seeing log messages that mention

malloc_error_break
then you’re corrupting memory. It might be that your high CPU usage is triggering that memory corruption, but the fix isn’t just to lower your CPU usage; you need to track down the cause of the corruption as well.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you for the reply.


I was under the impression that apple does not allow high CPU usage in the background and therefore I was having problems. How would you advise that I look for this cause of corruption?


Best,


F

I was under the impression that apple does not allow high CPU usage …

There certainly are CPU usage budgets for background processes but the symptoms you’ve described don’t match up with that.

How would you advise that I look for this cause of corruption?

If you can reproduce the problem with the debugger attached, set a breakpoint on

malloc_error_break
and then look at the backtrace to see what sort of memory is involved.

If not, you should look to the standard memory corruption debugging tools, including:

  • Zombies

  • Address sanitiser

  • Guard malloc

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

WWDC runs Mon, 5 Jun through to Fri, 9 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face. http://developer.apple.com/wwdc/