I've been trying Valgrind out with the following program:
#include <cstdlib>
#define BUF_SIZE 1000
int main() {
char *path = new char[BUF_SIZE]
return 0;
}
Evidently the program has a memory leak, but when I test Valgrind I get a lot of unrelated leak errors, in addition to the actual leak.
I installed Valgrind using the instructions I found in: https://www.gungorbudak.com/blog/2018/04/28/how-to-install-valgrind-on-macos-high-sierra/
I even tried the use --suppressions with darwin*.supp (from the Git Repository https://sourceware.org/git/?p=valgrind.git)
Any suggestions or advice will be welcome.
ARIAS-CSC-MBP:cpp arias$ valgrind --leak-check=yes ./test
==72896== Memcheck, a memory error detector
==72896== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==72896== Using Valgrind-3.14.0.GIT and LibVEX; rerun with -h for copyright info
==72896== Command: ./test
==72896==
==72896==
==72896== HEAP SUMMARY:
==72896== in use at exit: 19,411 bytes in 167 blocks
==72896== total heap usage: 188 allocs, 21 frees, 27,859 bytes allocated
==72896==
==72896== 64 bytes in 1 blocks are definitely lost in loss record 27 of 47
==72896== at 0x1000ACC32: calloc (in /usr/local/Cellar/valgrind/HEAD-5f900ed/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==72896== by 0x10075ABA4: realizeClass(objc_class*) (in /usr/lib/libobjc.A.dylib)
==72896== by 0x10075AC5A: realizeClass(objc_class*) (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100759363: _read_images (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100757AC4: map_images_nolock (in /usr/lib/libobjc.A.dylib)
==72896== by 0x10076A7DA: objc_object::sidetable_retainCount() (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100007C64: dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) (in /usr/lib/dyld)
==72896== by 0x100007E39: dyld::registerObjCNotifiers(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*)) (in /usr/lib/dyld)
==72896== by 0x10022271D: _dyld_objc_notify_register (in /usr/lib/system/libdyld.dylib)
==72896== by 0x100757075: _objc_init (in /usr/lib/libobjc.A.dylib)
==72896== by 0x1001ACB34: _os_object_init (in /usr/lib/system/libdispatch.dylib)
==72896== by 0x1001ACB1B: libdispatch_init (in /usr/lib/system/libdispatch.dylib)
==72896==
==72896== 64 bytes in 1 blocks are definitely lost in loss record 28 of 47
==72896== at 0x1000ACC32: calloc (in /usr/local/Cellar/valgrind/HEAD-5f900ed/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==72896== by 0x10075ABA4: realizeClass(objc_class*) (in /usr/lib/libobjc.A.dylib)
==72896== by 0x10075AC72: realizeClass(objc_class*) (in /usr/lib/libobjc.A.dylib)
==72896== by 0x10075AC5A: realizeClass(objc_class*) (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100759363: _read_images (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100757AC4: map_images_nolock (in /usr/lib/libobjc.A.dylib)
==72896== by 0x10076A7DA: objc_object::sidetable_retainCount() (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100007C64: dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) (in /usr/lib/dyld)
==72896== by 0x100007E39: dyld::registerObjCNotifiers(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*)) (in /usr/lib/dyld)
==72896== by 0x10022271D: _dyld_objc_notify_register (in /usr/lib/system/libdyld.dylib)
==72896== by 0x100757075: _objc_init (in /usr/lib/libobjc.A.dylib)
==72896== by 0x1001ACB34: _os_object_init (in /usr/lib/system/libdispatch.dylib)
==72896==
==72896== 72 bytes in 3 blocks are possibly lost in loss record 29 of 47
==72896== at 0x1000ACC32: calloc (in /usr/local/Cellar/valgrind/HEAD-5f900ed/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==72896== by 0x1007577E2: map_images_nolock (in /usr/lib/libobjc.A.dylib)
==72896== by 0x10076A7DA: objc_object::sidetable_retainCount() (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100007C64: dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) (in /usr/lib/dyld)
==72896== by 0x100007E39: dyld::registerObjCNotifiers(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*)) (in /usr/lib/dyld)
==72896== by 0x10022271D: _dyld_objc_notify_register (in /usr/lib/system/libdyld.dylib)
==72896== by 0x100757075: _objc_init (in /usr/lib/libobjc.A.dylib)
==72896== by 0x1001ACB34: _os_object_init (in /usr/lib/system/libdispatch.dylib)
==72896== by 0x1001ACB1B: libdispatch_init (in /usr/lib/system/libdispatch.dylib)
==72896== by 0x1000BB9C2: libSystem_initializer (in /usr/lib/libSystem.B.dylib)
==72896== by 0x100019AC5: ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==72896== by 0x100019CF5: ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==72896==
==72896== 1,000 bytes in 1 blocks are definitely lost in loss record 39 of 47
==72896== at 0x1000ACC32: calloc (in /usr/local/Cellar/valgrind/HEAD-5f900ed/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==72896== by 0x100000EF1: main (anothertest.cpp:8)
==72896==
==72896== 1,792 bytes in 28 blocks are definitely lost in loss record 44 of 47
==72896== at 0x1000ACC32: calloc (in /usr/local/Cellar/valgrind/HEAD-5f900ed/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==72896== by 0x10075ABA4: realizeClass(objc_class*) (in /usr/lib/libobjc.A.dylib)
==72896== by 0x10075AC72: realizeClass(objc_class*) (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100759363: _read_images (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100757AC4: map_images_nolock (in /usr/lib/libobjc.A.dylib)
==72896== by 0x10076A7DA: objc_object::sidetable_retainCount() (in /usr/lib/libobjc.A.dylib)
==72896== by 0x100007C64: dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) (in /usr/lib/dyld)
==72896== by 0x100007E39: dyld::registerObjCNotifiers(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*)) (in /usr/lib/dyld)
==72896== by 0x10022271D: _dyld_objc_notify_register (in /usr/lib/system/libdyld.dylib)
==72896== by 0x100757075: _objc_init (in /usr/lib/libobjc.A.dylib)
==72896== by 0x1001ACB34: _os_object_init (in /usr/lib/system/libdispatch.dylib)
==72896== by 0x1001ACB1B: libdispatch_init (in /usr/lib/system/libdispatch.dylib)
==72896==
==72896== LEAK SUMMARY:
==72896== definitely lost: 2,920 bytes in 31 blocks
==72896== indirectly lost: 0 bytes in 0 blocks
==72896== possibly lost: 72 bytes in 3 blocks
==72896== still reachable: 200 bytes in 6 blocks
==72896== suppressed: 16,219 bytes in 127 blocks
==72896== Reachable blocks (those to which a pointer was found) are not shown.
==72896== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==72896==
==72896== For counts of detected and suppressed errors, rerun with: -v
==72896== ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 16 from 16)
Valgrind is currently pre-release software for macOS High Sierra. As Valgrind needs to hook at a low level into the macOS kernel (mach) it needs continual tweaking upon each major new release of macOS.
At present, that means even using development Git versions of Valgrind, there will be false-positive errors (or at least memory errors which you can do nothing about) in library code which runs within the process space of your small test executable.
Future development releases of Valgrind may addresses these system errors. You can comfortably ignore them if not reporting problems in your own code.
I have googled all the planet without any solution to my problem.
Here is the hs_err_pid.log start file and the end
Let me know if you have any clue, because I have no idea how to solve it.
Excuse me for the presentation, I am beginner.
Thank you guys
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f5589b6c480, pid=7353, tid=139994995676928
#
# JRE version: OpenJDK Runtime Environment (7.0_121) (build 1.7.0_121-b00)
# Java VM: OpenJDK 64-Bit Server VM (24.121-b00 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 2.6.8
# Distribution: Gentoo Base System release 2.2, package Gentoo icedtea-7.2.6.8
# Problematic frame:
# C [libc.so.6+0x8e480]
#
# Core dump written. Default location: /opt/tomcat/7.0.78/logs/core or core.7353
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
# http://icedtea.classpath.org/bugzilla
#
--------------- T H R E A D ---------------
Current thread (0x00007f558012a000): JavaThread "http-bio-8443-exec-2" daemon [_thread_in_vm, id=7775, stack(0x00007f531fbcd000,0x00007f531ffce000)]
siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x0000000000000000
Registers:
RAX=0xfffffff84484b640, RBX=0x00007f558012a000, RCX=0x000000000911ea30, RDX=0x000000000488f518
RSP=0x00007f531ffcbe98, RBP=0x00007f531ffcbf10, RSI=0x0000000000000000, RDI=0x00000007b6f254a8
R8 =0x0000000000000000, R9 =0x00007f5580018598, R10=0x000000000488f528, R11=0xfffffffffffffff8
R12=0x000000000488f518, R13=0x0000000000000000, R14=0x00007f558012a1d8, R15=0x00007f5505578620
RIP=0x00007f5589b6c480, EFLAGS=0x0000000000010202, CSGSFS=0x0f19000000000033, ERR=0x0000000000000004
TRAPNO=0x000000000000000e
Top of Stack: (sp=0x00007f531ffcbe98)
0x00007f531ffcbe98: 00007f5589092baa 00007f558012a000
0x00007f531ffcbea8: 0000000000000000 00007f558012a000
0x00007f531ffcbeb8: 0000000000000000 00007f531ffcbee0
0x00007f531ffcbec8: 00007f55890a3d9b 00007f558012a000
0x00007f531ffcbed8: bb924a63a8aa2700 00007f531ffcbf10
0x00007f531ffcbee8: 00007f558012a000 00007f558012a1d8
0x00007f531ffcbef8: 00007f5505578620 000000000488f518
0x00007f531ffcbf08: 0000000000000000 00007f531ffcbf60
0x00007f531ffcbf18: 00007f55890a80f1 00007f558012a1d8
0x00007f531ffcbf28: 000000000488f3b0 00007f531ffcbf60
0x00007f531ffcbf38: 00007f558012a1d8 00007f5505578620
0x00007f531ffcbf48: 00007f550488f3b0 00007f531ffcc0a8
0x00007f531ffcbf58: 0000000000000042 00007f531ffcbf90
0x00007f531ffcbf68: 00007f55033c8150 00007f5504821850
0x00007f531ffcbf78: 00007f558012a1d8 00007f5504821850
0x00007f531ffcbf88: 00007f5505578618 00007f531ffcc010
0x00007f531ffcbf98: 00007f55033c82ba 0000000400c80ec8
0x00007f531ffcbfa8: 000000428012afe8 00007f550488f2a0
0x00007f531ffcbfb8: 00007f550488ea90 00007f531ffcc000
0x00007f531ffcbfc8: 00007f55048218a0 000000b80000000a
0x00007f531ffcbfd8: bb924a63a8aa2700 0000000400c80ec8
0x00007f531ffcbfe8: 0000000400c80ec8 0000000000000000
0x00007f531ffcbff8: 0000000400c80ec0 00007f531ffcc0b0
0x00007f531ffcc008: 00007f558012a000 00007f531ffcc080
0x00007f531ffcc018: 00007f557d014e98 00007f558012b008
0x00007f531ffcc028: 00007f558012b008 00007f53fffffffe
0x00007f531ffcc038: 0000000000000000 00007f531ffcc040
0x00007f531ffcc048: 0000000400c80ec0 00007f531ffcc0b0
0x00007f531ffcc058: 0000000400c81ff8 0000000000000000
0x00007f531ffcc068: 0000000400c80ec8 0000000000000000
0x00007f531ffcc078: 00007f531ffcc0a0 00007f531ffcc0f8
0x00007f531ffcc088: 00007f557d00634b 0000000617228f10
Instructions: (pc=0x00007f5589b6c480)
0x00007f5589b6c460: 48 89 f0 48 8d 0c 12 48 29 f8 48 29 d0 48 39 c8
0x00007f5589b6c470: 0f 82 07 01 00 00 48 83 fa 10 0f 86 8b 01 00 00
0x00007f5589b6c480: f3 44 0f 6f 06 48 83 fa 20 f3 44 0f 7f 07 f3 44
0x00007f5589b6c490: 0f 6f 44 16 f0 f3 44 0f 7f 44 17 f0 77 12 48 89
Register to memory mapping:
RAX=0xfffffff84484b640 is an unknown value
RBX=0x00007f558012a000 is a thread
RCX=0x000000000911ea30 is an unknown value
RDX=0x000000000488f518 is an unknown value
RSP=0x00007f531ffcbe98 is pointing into the stack for thread: 0x00007f558012a000
RBP=0x00007f531ffcbf10 is pointing into the stack for thread: 0x00007f558012a000
RSI=0x0000000000000000 is an unknown value
RDI=0x00000007b6f254a8 is an unknown value
R8 =0x0000000000000000 is an unknown value
R9 =0x00007f5580018598 is an unknown value
R10=0x000000000488f528 is an unknown value
R11=0xfffffffffffffff8 is an unknown value
R12=0x000000000488f518 is an unknown value
R13=0x0000000000000000 is an unknown value
R14=0x00007f558012a1d8 is an unknown value
R15=0x00007f5505578620 is an unknown value
Stack: [0x00007f531fbcd000,0x00007f531ffce000], sp=0x00007f531ffcbe98, free space=4091k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libc.so.6+0x8e480]
V [libjvm.so+0x6380f1]
C [libsunec.so+0x1150]
C [libsunec.so+0x12ba] Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair+0x12a
j sun.security.ec.ECKeyPairGenerator.generateECKeyPair(I[B[B)[Ljava/lang/Object;+0
j sun.security.ec.ECKeyPairGenerator.generateKeyPair()Ljava/security/KeyPair;+55
j java.security.KeyPairGenerator$Delegate.generateKeyPair()Ljava/security/KeyPair;+23
j sun.security.ssl.ECDHCrypt.<init>(Ljava/lang/String;Ljava/security/SecureRandom;)V+28
j sun.security.ssl.ServerHandshaker.setupEphemeralECDHKeys()Z+88
j sun.security.ssl.ServerHandshaker.trySetCipherSuite(Lsun/security/ssl/CipherSuite;)Z+638
j sun.security.ssl.ServerHandshaker.chooseCipherSuite(Lsun/security/ssl/HandshakeMessage$ClientHello;)V+119
j sun.security.ssl.ServerHandshaker.clientHello(Lsun/security/ssl/HandshakeMessage$ClientHello;)V+1134
j sun.security.ssl.ServerHandshaker.processMessage(BI)V+127
j sun.security.ssl.Handshaker.processLoop()V+96
j sun.security.ssl.Handshaker.process_record(Lsun/security/ssl/InputRecord;Z)V+24
j sun.security.ssl.SSLSocketImpl.readRecord(Lsun/security/ssl/InputRecord;Z)V+353
j sun.security.ssl.SSLSocketImpl.performInitialHandshake()V+84
j sun.security.ssl.SSLSocketImpl.startHandshake(Z)V+13
j sun.security.ssl.SSLSocketImpl.getSession()Ljavax/net/ssl/SSLSession;+10
j org.apache.tomcat.util.net.jsse.JSSESocketFactory.handshake(Ljava/net/Socket;)V+4
j org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run()V+30
j java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V+95
j java.util.concurrent.ThreadPoolExecutor$Worker.run()V+5
j org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run()V+4
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub
V [libjvm.so+0x608a84]
V [libjvm.so+0x6077ae]
V [libjvm.so+0x6441af]
V [libjvm.so+0x940fba]
V [libjvm.so+0x94135a]
V [libjvm.so+0x803842]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j sun.security.ec.ECKeyPairGenerator.generateECKeyPair(I[B[B)[Ljava/lang/Object;+0
j sun.security.ec.ECKeyPairGenerator.generateKeyPair()Ljava/security/KeyPair;+55
j java.security.KeyPairGenerator$Delegate.generateKeyPair()Ljava/security/KeyPair;+23
j sun.security.ssl.ECDHCrypt.<init>(Ljava/lang/String;Ljava/security/SecureRandom;)V+28
j sun.security.ssl.ServerHandshaker.setupEphemeralECDHKeys()Z+88
j sun.security.ssl.ServerHandshaker.trySetCipherSuite(Lsun/security/ssl/CipherSuite;)Z+638
j sun.security.ssl.ServerHandshaker.chooseCipherSuite(Lsun/security/ssl/HandshakeMessage$ClientHello;)V+119
j sun.security.ssl.ServerHandshaker.clientHello(Lsun/security/ssl/HandshakeMessage$ClientHello;)V+1134
j sun.security.ssl.ServerHandshaker.processMessage(BI)V+127
j sun.security.ssl.Handshaker.processLoop()V+96
j sun.security.ssl.Handshaker.process_record(Lsun/security/ssl/InputRecord;Z)V+24
j sun.security.ssl.SSLSocketImpl.readRecord(Lsun/security/ssl/InputRecord;Z)V+353
j sun.security.ssl.SSLSocketImpl.performInitialHandshake()V+84
j sun.security.ssl.SSLSocketImpl.startHandshake(Z)V+13
j sun.security.ssl.SSLSocketImpl.getSession()Ljavax/net/ssl/SSLSession;+10
j org.apache.tomcat.util.net.jsse.JSSESocketFactory.handshake(Ljava/net/Socket;)V+4
j org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run()V+30
j java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V+95
j java.util.concurrent.ThreadPoolExecutor$Worker.run()V+5
j org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run()V+4
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x00007f55802e0800 JavaThread "http-bio-8443-AsyncTimeout" daemon [_thread_blocked, id=7785, stack(0x00007f531d3c3000,0x00007f531d7c4000)]
0x00007f55802de800 JavaThread "http-bio-8443-Acceptor-0" daemon [_thread_in_native, id=7784, stack(0x00007f531d7c4000,0x00007f531dbc5000)]
0x00007f55802dc800 JavaThread "http-bio-8443-exec-10" daemon [_thread_blocked, id=7783, stack(0x00007f531dbc5000,0x00007f531dfc6000)]
0x00007f55802da800 JavaThread "http-bio-8443-exec-9" daemon [_thread_blocked, id=7782, stack(0x00007f531dfc6000,0x00007f531e3c7000)]
.....
VM Mutex/Monitor currently owned by a thread: None
Heap
PSYoungGen total 1715712K, used 1187554K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1321984K, 73% used [0x0000000780000000,0x00000007bb7b49c0,0x00000007d0b00000)
from space 393728K, 54% used [0x00000007e7f80000,0x00000007f4f84178,0x0000000800000000)
to space 381440K, 0% used [0x00000007d0b00000,0x00000007d0b00000,0x00000007e7f80000)
ParOldGen total 6291456K, used 987789K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 15% used [0x0000000600000000,0x000000063c4a35d8,0x0000000780000000)
PSPermGen total 4194304K, used 531336K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 12% used [0x0000000400000000,0x00000004206e23c8,0x0000000500000000)
Card table byte_map: [0x00007f5584d73000,0x00007f5586d74000] byte_map_base: 0x00007f5582d73000
Polling page: 0x00007f558a6c7000
Code Cache [0x00007f557d000000, 0x00007f557dec0000, 0x00007f5580000000)
total_blobs=4948 nmethods=4244 adapters=664 free_code_cache=34359Kb largest_free_block=34927552
Compilation events (10 events):
Event: 133.271 Thread 0x00007f55800be800 nmethod 4792 0x00007f557ddd32d0 code [0x00007f557ddd3400, 0x00007f557ddd3498]
Event: 133.282 Thread 0x00007f55800be800 4793 sun.nio.cs.CharsetMapping::readCharArray (112 bytes)
Event: 133.288 Thread 0x00007f55800be800 nmethod 4793 0x00007f557de74210 code [0x00007f557de74360, 0x00007f557de74778]
Event: 133.291 Thread 0x00007f55800c1000 nmethod 4791 0x00007f557de78d50 code [0x00007f557de78f40, 0x00007f557de7a1d0]
Event: 133.331 Thread 0x00007f55800be800 4794 % java.util.Properties$LineReader::readLine # 21 (452 bytes)
Event: 133.339 Thread 0x00007f55800be800 nmethod 4794% 0x00007f557dd8e110 code [0x00007f557dd8e2a0, 0x00007f557dd8eb98]
Event: 133.456 Thread 0x00007f55800c1000 4795 java.util.Properties$LineReader::readLine (452 bytes)
Event: 133.465 Thread 0x00007f55800c1000 nmethod 4795 0x00007f557dd89cd0 code [0x00007f557dd89e60, 0x00007f557dd8a618]
Event: 133.838 Thread 0x00007f55800be800 4796 org.postgresql.core.Parser::parseSingleQuotes (134 bytes)
Event: 133.841 Thread 0x00007f55800be800 nmethod 4796 0x00007f557de1d810 code [0x00007f557de1d960, 0x00007f557de1dbf8]
GC Heap History (10 events):
Event: 99.316 GC heap before
{Heap before GC invocations=16 (full 0):
PSYoungGen total 1662464K, used 1428685K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1230848K, 100% used [0x0000000780000000,0x00000007cb200000,0x00000007cb200000)
from space 431616K, 45% used [0x00000007cb200000,0x00000007d7333600,0x00000007e5780000)
to space 425472K, 0% used [0x00000007e6080000,0x00000007e6080000,0x0000000800000000)
ParOldGen total 6291456K, used 813260K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 12% used [0x0000000600000000,0x0000000631a330c8,0x0000000780000000)
PSPermGen total 4194304K, used 412966K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 9% used [0x0000000400000000,0x0000000419349ba0,0x0000000500000000)
Event: 99.399 GC heap after
Heap after GC invocations=16 (full 0):
PSYoungGen total 1678848K, used 196634K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1253376K, 0% used [0x0000000780000000,0x0000000780000000,0x00000007cc800000)
from space 425472K, 46% used [0x00000007e6080000,0x00000007f2086a98,0x0000000800000000)
to space 418304K, 0% used [0x00000007cc800000,0x00000007cc800000,0x00000007e6080000)
ParOldGen total 6291456K, used 845202K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 13% used [0x0000000600000000,0x0000000633964900,0x0000000780000000)
PSPermGen total 4194304K, used 412966K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 9% used [0x0000000400000000,0x0000000419349ba0,0x0000000500000000)
}
Event: 108.691 GC heap before
{Heap before GC invocations=17 (full 0):
PSYoungGen total 1678848K, used 1450010K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1253376K, 100% used [0x0000000780000000,0x00000007cc800000,0x00000007cc800000)
from space 425472K, 46% used [0x00000007e6080000,0x00000007f2086a98,0x0000000800000000)
to space 418304K, 0% used [0x00000007cc800000,0x00000007cc800000,0x00000007e6080000)
ParOldGen total 6291456K, used 845202K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 13% used [0x0000000600000000,0x0000000633964900,0x0000000780000000)
PSPermGen total 4194304K, used 431803K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 10% used [0x0000000400000000,0x000000041a5aeec8,0x0000000500000000)
Event: 108.774 GC heap after
Heap after GC invocations=17 (full 0):
PSYoungGen total 1671680K, used 190846K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1253376K, 0% used [0x0000000780000000,0x0000000780000000,0x00000007cc800000)
from space 418304K, 45% used [0x00000007cc800000,0x00000007d825f840,0x00000007e6080000)
to space 411648K, 0% used [0x00000007e6e00000,0x00000007e6e00000,0x0000000800000000)
ParOldGen total 6291456K, used 881007K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 14% used [0x0000000600000000,0x0000000635c5bd70,0x0000000780000000)
PSPermGen total 4194304K, used 431803K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 10% used [0x0000000400000000,0x000000041a5aeec8,0x0000000500000000)
}
Event: 114.421 GC heap before
{Heap before GC invocations=18 (full 0):
PSYoungGen total 1671680K, used 1444222K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1253376K, 100% used [0x0000000780000000,0x00000007cc800000,0x00000007cc800000)
from space 418304K, 45% used [0x00000007cc800000,0x00000007d825f840,0x00000007e6080000)
to space 411648K, 0% used [0x00000007e6e00000,0x00000007e6e00000,0x0000000800000000)
ParOldGen total 6291456K, used 881007K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 14% used [0x0000000600000000,0x0000000635c5bd70,0x0000000780000000)
PSPermGen total 4194304K, used 447970K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 10% used [0x0000000400000000,0x000000041b5789f8,0x0000000500000000)
Event: 114.505 GC heap after
Heap after GC invocations=18 (full 0):
PSYoungGen total 1697280K, used 212260K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1285632K, 0% used [0x0000000780000000,0x0000000780000000,0x00000007ce780000)
from space 411648K, 51% used [0x00000007e6e00000,0x00000007f3d49188,0x0000000800000000)
to space 399872K, 0% used [0x00000007ce780000,0x00000007ce780000,0x00000007e6e00000)
ParOldGen total 6291456K, used 913317K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 14% used [0x0000000600000000,0x0000000637be9728,0x0000000780000000)
PSPermGen total 4194304K, used 447970K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 10% used [0x0000000400000000,0x000000041b5789f8,0x0000000500000000)
}
Event: 123.134 GC heap before
{Heap before GC invocations=19 (full 0):
PSYoungGen total 1697280K, used 1497892K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1285632K, 100% used [0x0000000780000000,0x00000007ce780000,0x00000007ce780000)
from space 411648K, 51% used [0x00000007e6e00000,0x00000007f3d49188,0x0000000800000000)
to space 399872K, 0% used [0x00000007ce780000,0x00000007ce780000,0x00000007e6e00000)
ParOldGen total 6291456K, used 913317K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 14% used [0x0000000600000000,0x0000000637be9728,0x0000000780000000)
PSPermGen total 4194304K, used 480230K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 11% used [0x0000000400000000,0x000000041d4f9b90,0x0000000500000000)
Event: 123.218 GC heap after
Heap after GC invocations=19 (full 0):
PSYoungGen total 1685504K, used 182843K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1285632K, 0% used [0x0000000780000000,0x0000000780000000,0x00000007ce780000)
from space 399872K, 45% used [0x00000007ce780000,0x00000007d9a0ecf0,0x00000007e6e00000)
to space 393728K, 0% used [0x00000007e7f80000,0x00000007e7f80000,0x0000000800000000)
ParOldGen total 6291456K, used 946748K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 15% used [0x0000000600000000,0x0000000639c8f218,0x0000000780000000)
PSPermGen total 4194304K, used 480230K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 11% used [0x0000000400000000,0x000000041d4f9b90,0x0000000500000000)
}
Event: 128.937 GC heap before
{Heap before GC invocations=20 (full 0):
PSYoungGen total 1685504K, used 1468475K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1285632K, 100% used [0x0000000780000000,0x00000007ce780000,0x00000007ce780000)
from space 399872K, 45% used [0x00000007ce780000,0x00000007d9a0ecf0,0x00000007e6e00000)
to space 393728K, 0% used [0x00000007e7f80000,0x00000007e7f80000,0x0000000800000000)
ParOldGen total 6291456K, used 946748K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 15% used [0x0000000600000000,0x0000000639c8f218,0x0000000780000000)
PSPermGen total 4194304K, used 496294K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 11% used [0x0000000400000000,0x000000041e4a9b58,0x0000000500000000)
Event: 129.028 GC heap after
Heap after GC invocations=20 (full 0):
PSYoungGen total 1715712K, used 213008K [0x0000000780000000, 0x0000000800000000, 0x0000000800000000)
eden space 1321984K, 0% used [0x0000000780000000,0x0000000780000000,0x00000007d0b00000)
from space 393728K, 54% used [0x00000007e7f80000,0x00000007f4f84178,0x0000000800000000)
to space 381440K, 0% used [0x00000007d0b00000,0x00000007d0b00000,0x00000007e7f80000)
ParOldGen total 6291456K, used 987789K [0x0000000600000000, 0x0000000780000000, 0x0000000780000000)
object space 6291456K, 15% used [0x0000000600000000,0x000000063c4a35d8,0x0000000780000000)
PSPermGen total 4194304K, used 496294K [0x0000000400000000, 0x0000000500000000, 0x0000000600000000)
object space 4194304K, 11% used [0x0000000400000000,0x000000041e4a9b58,0x0000000500000000)
}
Deoptimization events (10 events):
Event: 133.447 Thread 0x00007f558015f800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00007f557d455ca4 method=java.lang.Character.isUpperCase(I)Z # 5
Event: 133.447 Thread 0x00007f558015f800 Uncommon trap: reason=class_check action=maybe_recompile pc=0x00007f557d674dac method=java.beans.Introspector.processPropertyDescriptors()V # 91
Event: 133.448 Thread 0x00007f558015f800 Uncommon trap: reason=class_check action=maybe_recompile pc=0x00007f557d674dac method=java.beans.Introspector.processPropertyDescriptors()V # 91
Event: 133.448 Thread 0x00007f558015f800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00007f557d4566e4 method=java.lang.Character.isUpperCase(I)Z # 5
Event: 133.449 Thread 0x00007f558015f800 Uncommon trap: reason=class_check action=maybe_recompile pc=0x00007f557d674dac method=java.beans.Introspector.processPropertyDescriptors()V # 91
Event: 133.454 Thread 0x00007f558015f800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00007f557d2cb5c4 method=java.nio.Buffer.limit(I)Ljava/nio/Buffer; # 33
Event: 133.459 Thread 0x00007f558015f800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00007f557d7226ec method=java.nio.charset.CharsetDecoder.decode(Ljava/nio/ByteBuffer;Ljava/nio/CharBuffer;Z)Ljava/nio/charset/CoderResult; # 1
Event: 140.285 Thread 0x00007f5580128000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00007f557dd5c1c8 method=sun.security.util.AbstractAlgorithmConstraints.checkAlgorithm([Ljava/lang/String;Ljava/lang/String;Lsun/security/util/AlgorithmDecomposer;)Z # 70
Event: 140.288 Thread 0x00007f558012a000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00007f557d19cb90 method=java.io.ByteArrayInputStream.read([BII)I # 70
Event: 140.289 Thread 0x00007f5580128000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00007f557d19cb90 method=java.io.ByteArrayInputStream.read([BII)I # 70
Internal exceptions (10 events):
Event: 133.458 Thread 0x00007f558015f800 Threw 0x00000007ae646ec0 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Event: 133.458 Thread 0x00007f558015f800 Threw 0x00000007ae647620 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Event: 133.458 Thread 0x00007f558015f800 Threw 0x00000007ae64a7c8 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Event: 133.458 Thread 0x00007f558015f800 Threw 0x00000007ae64af78 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Event: 133.459 Thread 0x00007f558015f800 Threw 0x00000007ae64e800 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Event: 133.459 Thread 0x00007f558015f800 Threw 0x00000007ae64f008 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Event: 133.460 Thread 0x00007f558015f800 Threw 0x00000007ae652348 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Event: 133.460 Thread 0x00007f558015f800 Threw 0x00000007ae652b58 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Event: 135.204 Thread 0x00007f54f4d23800 Threw 0x00000007ae82a358 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Event: 139.962 Thread 0x00007f54f4fab000 Threw 0x00000007aed1c080 at /var/tmp/notmpfs/portage/dev-java/icedtea-7.2.6.8/work/icedtea-2.6.8/openjdk/hotspot/src/share/vm/prims/jvm.cpp:1322
Events (10 events):
Event: 140.290 loading class 0x00007f55043e2ff0
Event: 140.290 loading class 0x00007f55043e2ff0 done
Event: 140.290 loading class 0x00007f55043e2da0
Event: 140.290 loading class 0x00007f55043e2da0 done
Event: 140.291 loading class 0x00007f55043e3b30
Event: 140.291 loading class 0x00007f55043e3b30 done
Event: 140.291 loading class 0x00007f55043e3550
Event: 140.291 loading class 0x00007f55043e3550 done
Event: 140.291 loading class 0x00007f55804696e0
Event: 140.291 loading class 0x00007f55804696e0 done
Dynamic libraries:
003ff000-00400000 rw-p 00000000 08:03 18490064 /opt/icedtea-bin-7.2.6.8/bin/java
00400000-00401000 r-xp 00001000 08:03 18490064 /opt/icedtea-bin-7.2.6.8/bin/java
00600000-00601000 r--p 00001000 08:03 18490064 /opt/icedtea-bin-7.2.6.8/bin/java
00601000-00602000 rw-p 00002000 08:03 18490064 /opt/icedtea-bin-7.2.6.8/bin/java
01988000-019a9000 rw-p 00000000 00:00 0 [heap]
.....
VM Arguments:
jvm_args: -Djava.util.logging.config.file=/opt/tomcat/7.0.78/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Xms4096m -Xmx4096m -XX:NewSize=2048m -XX:MaxNewSize=2048m -XX:PermSize=4096m -XX:MaxPermSize=4096m -XX:+DisableExplicitGC -XX:+HeapDumpOnOutOfMemoryError -Xcheck:jni -Xms8192m -Xmx8192m -XX:MaxPermSize=8192m -Xss4096k -XX:+UseParallelGC -XX:MaxGCPauseMillis=1500 -XX:GCTimeRatio=9 -XX:+DisableExplicitGC -Djava.endorsed.dirs=/opt/tomcat/7.0.78/endorsed -Dcatalina.base=/opt/tomcat/7.0.78 -Dcatalina.home=/opt/tomcat/7.0.78 -Djava.io.tmpdir=/opt/tomcat/7.0.78/temp
java_command: org.apache.catalina.startup.Bootstrap start
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=/etc/java-config-2/current-system-vm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.4
SHELL=/bin/bash
DISPLAY=localhost:10.0
Signal Handlers:
SIGSEGV: [libjvm.so+0x996df0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGBUS: [libjvm.so+0x996df0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGFPE: [libjvm.so+0x801c80], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGPIPE: SIG_IGN, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGXFSZ: [libjvm.so+0x801c80], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGILL: [libjvm.so+0x801c80], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGUSR2: [libjvm.so+0x801db0], sa_mask[0]=0x00000000, sa_flags=0x10000004
SIGHUP: [libjvm.so+0x801d00], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGINT: SIG_IGN, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGTERM: [libjvm.so+0x801d00], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGQUIT: [libjvm.so+0x801d00], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGTRAP: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
--------------- S Y S T E M ---------------
OS:Gentoo Base System release 2.3
uname:Linux 4.4.6-gentoo #1 SMP Fri Jul 22 14:10:27 CEST 2016 x86_64
libc:glibc 2.23 NPTL 2.23
rlimit: STACK 8192k, CORE infinity, NPROC 63651, NOFILE 4096, AS infinity
load average:0.44 0.27 2.74
/proc/meminfo:
MemTotal: 16328680 kB
MemFree: 4797700 kB
MemAvailable: 11312328 kB
Buffers: 586184 kB
Cached: 6091712 kB
SwapCached: 6488 kB
Active: 7015680 kB
Inactive: 3838568 kB
Active(anon): 4578024 kB
Inactive(anon): 170920 kB
Active(file): 2437656 kB
Inactive(file): 3667648 kB
Unevictable: 7444 kB
Mlocked: 7444 kB
SwapTotal: 972796 kB
SwapFree: 860668 kB
Dirty: 460 kB
Writeback: 0 kB
AnonPages: 4183196 kB
Mapped: 712856 kB
Shmem: 566544 kB
Slab: 549900 kB
SReclaimable: 469876 kB
SUnreclaim: 80024 kB
KernelStack: 13760 kB
PageTables: 47748 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 9137136 kB
Committed_AS: 17231004 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 3195776 kB
DirectMap2M: 13502464 kB
DirectMap1G: 0 kB
CPU:total 16 (8 cores per cpu, 2 threads per core) family 6 model 45 stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, aes, ht, tsc, tscinvbit, tscinv
.....
Memory: 4k page, physical 16328680k(4797700k free), swap 972796k(860668k free)
vm_info: OpenJDK 64-Bit Server VM (24.121-b00) for linux-amd64 JRE (1.7.0_121-b00), built on Nov 19 2016 12:19:28 by "portage" with gcc 4.9.3
time: Fri Jun 23 11:39:29 2017
elapsed time: 140 seconds
I have an audio program that makes a call to AudioConverterFillComplexBuffer with the following code:
OSStatus error = AudioConverterFillComplexBuffer(recorderObj->audioConverter,
MyAudioConverterCallback,
(__bridge void *)playerLocal,
&ioOutputDataPackets,
convertedData,
&streamDesc);
When this code runs on 10.6-10.11, it works fine. When the code runs on 10.12, it crashes with the following message
Crashed Thread: 16 com.apple.audio.IOThread.client
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
The call stack ends in CrashIfClientProvidedBogusAudioBufferList.
Most articles, documentation and mailing lists would say that I have a bad output buffer but for the life of me, I cannot tell what I would be doing wrong but still have my code work on all versions of MacOS but the latest. Here is how I am setting up the buffer:
AudioBufferList *convertedData = (AudioBufferList*)malloc(sizeof(AudioBufferList) * 2);
convertedData->mNumberBuffers = 1;
convertedData->mBuffers[0].mNumberChannels = 2;
convertedData->mBuffers[0].mDataByteSize = 64 * 1024;
convertedData->mBuffers[0].mData = (UInt8 *)malloc(sizeof(UInt8) * 64 * 1024);
Here is the full stack at the point of the crash
Thread 16 Crashed:: com.apple.audio.IOThread.client
0 com.apple.audio.toolbox.AudioToolbox 0x00007fff89b9a330 CADebuggerStop() + 4
1 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a21e71 CrashIfClientProvidedBogusAudioBufferList + 97
2 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f710 AudioConverterChain::CallInputProc(unsigned int) + 646
3 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f386 AudioConverterChain::FillBufferFromInputProc(unsigned int*, CABufferList*) + 130
4 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f2ee BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const*&) + 178
5 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f1b2 CBRConverter::RenderOutput(CABufferList*, unsigned int, unsigned int&, AudioStreamPacketDescription*) + 106
6 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2225d BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 281
7 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f2c3 BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const*&) + 135
8 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a9369b Resampler2Wrapper::RenderOutput(CABufferList*, unsigned int, unsigned int&) + 183
9 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2225d BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 281
10 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f2c3 BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const*&) + 135
11 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f1b2 CBRConverter::RenderOutput(CABufferList*, unsigned int, unsigned int&, AudioStreamPacketDescription*) + 106
12 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2225d BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 281
13 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2253f AudioConverterChain::RenderOutput(CABufferList*, unsigned int, unsigned int&, AudioStreamPacketDescription*) + 99
14 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2225d BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 281
15 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a21d2f AudioConverterFillComplexBuffer + 282
16 com.pc-intercom.Intercom 0x0000000107a52803 0x107a4a000 + 34819
17 com.apple.audio.units.Components 0x000000010a38c97c AUHAL::AUIOProc(unsigned int, AudioTimeStamp const*, AudioBufferList const*, AudioTimeStamp const*, AudioBufferList*, AudioTimeStamp const*, void*) + 2324
18 com.apple.audio.CoreAudio 0x00007fff8a71f951 HALC_ProxyIOContext::IOWorkLoop() + 4369
19 com.apple.audio.CoreAudio 0x00007fff8a71e667 HALC_ProxyIOContext::IOThreadEntry(void*) + 131
20 com.apple.audio.CoreAudio 0x00007fff8a71e38b HALB_IOThread::Entry(void*) + 75
21 libsystem_pthread.dylib 0x0000000108134aab _pthread_body + 180
22 libsystem_pthread.dylib 0x00000001081349f7 _pthread_start + 286
23 libsystem_pthread.dylib 0x0000000108134221 thread_start + 13
If anyone has any suggestions on how I can debug this issue, I would greatly appreciate the help.
In MyAudioConverterCallback, ioDataPacketCount is supposed to return frames for LPCM (I guess packets are frames for uncompressed audio), so set it to:
*ioDataPacketCount = recorderObj->inputBuffer->mBuffers[0].mDataByteSize/recorderObj->streamFormat.mBytesPerFrame;
Pass a NULL AudioStreamPacketDescription to AudioConverterFillComplexBuffer instead of an array of 1 (this was causing crashes for me on 10.11). Your destination format is LPCM, so packet descriptions are unnecessary because your "packets" are all the same size.
Similarly, your source format is LPCM too, so you can remove the code that returns packet descriptions in MyAudioConverterCallback - it's also wrong.
On my machine, I get non-interleaved stereo for streamFormat which means MyAudioConverterCallback has to fill out ioData->mBuffers[1] too.
When setting up your convertedData AudioBufferList, sizePerPacket was using the source format packet size instead of the destination packet size. It should be:
sizePerPacket = mOutputFormat.mBytesPerPacket;
And finally, even when it's not crashing, this code can't be right because you're recording (say) 512 frames from the microphone, then asking the audio converter to convert 16384 - that's going to give you audio glitches.
The callback is given an audio buffer list pointed to by ioData. This
buffer list may refer to existing buffers owned and allocated by the
audio converter, in which case the callback may use them and copy
input audio data into them. However, the buffer list may also be
empty (mDataByteSize == 0 and/or mData == NULL), in which case the
callback must provide its own buffers. The callback manipulates the
members of ioData to point to one or more buffers of audio data
(multiple buffers are used with non-interleaved PCM data). The
callback is responsible for not freeing or altering this buffer until
it is called again.
In the AudioConverterComplexInputDataProc callback, When I try to return a ioData with it's mBuffers[0].mData == NULL, I got this crash.