LimeSuiteNG memory allocation error under Mac OS

This could be a bit outside of normal topics here, but I thought I would try anyway. I found that I am able to compile and create the LimeSuiteNG library under MacOS using CMAKE. I am able to compile the example programs (e.g. basicTX and dualRXTX), but when I run them they don’t make it past the streaming setup stage (device->StreamSetup(stream, chipIndex)), and give the following error: “Failed to configure settings: Failed to allocate memory”. Let me know if you have any ideas.

Thanks in advance.

Hi, could you provide more information:
Which LimeSuiteNG version (git changeset) you used?
What are the specs of your MacOS machine?
Which LimeSDR device you are using?

Thanks - it is a MacBook M3 Pro running OS 14.7.1. The SDRs I am using are LimeSDR Mini v2.4. I am not sure about the git changeset, but I built the library on Nov 3 and it made liblimesuiteng.0.2.0.dylib (actually liblimesuiteng.0.2-1.dylib, but that is just a link back to the previous one).
I tried running the example programs that were built in cmake, and also re-made them in Xcode - same issue in each.
Let me know if there is any other information you need or suggestions.
Thanks!

Unfortunately I don’t have access to Apple machines, so I can’t debug it directly. Based on your description and clang compiler nuances, I suspect the fault is due to aligned memory allocation failure.
I’ve created a branch "macos-memory-issue" with that removed, I’d appreciate if you could test it.
Inside LimeSuiteNG directory do git pull then git checkout macos-memory-issue, then build as usual.

Hi @ricardas.

The issue is caused by TRXLooper requesting incompatible allocation size and alignment. In my case it is this call: mTx.memPool = std::make_unique<MemoryPool>(1024, upperAllocationLimit, 4096, name). The allocation size is 8232, and alignment is 4096.

From quick reading the doc std::aligned_malloc I’m not sure if that’s not supported at all, or not supported on some platforms.

Using the macos-memory-issue branch or aligning the allocation size to the 4096 boundary solves the crash.

Thanks for the response(s) - yes, the issue is now solved and I can make the library and run the examples without problem.
Thanks for your help!

Thanks for verifying. Indeed according to docs, the allocation size has to be multiple of alignment, otherwise depending on compiler version it’s undefined behaviour.
I’ve pushed the fix into main develop branch.

Lovely! I’ve checked the develop branch and the issue is indeed solved.