Crash in stream mode | LabJack

Crash in stream mode

3 posts / 0 new
Last post
cstawarz's picture
Crash in stream mode

I'm trying to use stream mode with a T7, and I'm finding my application crashes very quickly with an error saying "heap corruption detected".  Here are the details of my setup:

Device: LabJack T7
Firmware version: 1.0292
OS: macOS 12.2.1
LJM release: 2021/04/01 beta (LJM 1.2100)

I'm running on an arm64 (Apple M1) system, so my application executes via Rosetta translation.

I've attached an example program that produces the crash.  It's a slightly-modified version of stream_basic.c from the 2021/08/20 LJM C/C++ examples.  I compile it with the following command:

clang -arch x86_64 -lLabJackM stream_crash.c

When run, the resulting executable reliably crashes after a few seconds, with the following output:

a.out(94381,0x204d0d600) malloc: Heap corruption detected, free list is damaged at 0x6000034e98f0
*** Incorrect guard value: 0
a.out(94381,0x204d0d600) malloc: *** set a breakpoint in malloc_error_break to debug

I've tried running the test application using both Guard Malloc and Clang's address sanitizer, but unfortunately the crash doesn't happen in those scenarios.

Any thoughts on why this might be happening or how to fix it?


Chris Stawarz

File Attachment: 
LabJack Support
labjack support's picture
Does compiling with the -g

Does compiling with the -g flag provide any more debug information?

Since the issue does not seem to happen when running debug tools, I think there is a pretty good chance something unexpected is happening with the LJM binary due to the translation. A sort of brute forced check to try is compiling and running a basic example like eNames.c.

I will see if we can have someone try to reproduce the issue and follow up if we find anything.

We are hoping to have native M1 support soon, but I am not sure how soon we will have that available.

cstawarz's picture
No, compiling with -g does

No, compiling with -g does not provide any more information.

The crash only happens with stream mode.  If I read the same amount of data, at the same rate, using LJM_eReadAddresses, everything works fine.

Native M1 support will be very welcome!