Accelerate DFT function crashing on ARM64 hardware

Originator:google
Number:rdar://FB11662590 Date Originated:7 October 2022
Status:Open Resolved:
Product:Accelerate Framework Product Version:macOS 13.6
Classification:Application Crash Reproducible:Yes
 
On my M1 iMac 24” 2021 using vDSP_DFT_SetupD() to create a new vDSP_DFT_SetupD structure that is half the size of the previous one causes vDSP_DFT_ExecuteD() to crash. This issue does not affect the x86_64 executable, which runs correctly on x86_64 hardware and under Rosetta emulation.

The attached command line tool demonstrates the problem. When run the results expected are:

    Starting
    Setup 1 created
    Setup 1 executed
    Setup 2 created
    Setup 1 destroyed
    Setup 2 executed
    Setup 2 destroyed
    Finished
    Program ended with exit code: 0

The results I actually see on M1 hardware are:

    Starting
    Setup 1 created
    Setup 1 executed
    Setup 2 created
    Setup 1 destroyed
    zsh: segmentation fault  ./DFTbug

With the stack trace in Xcode:

    Thread 1: EXC_BAD_ACCESS (code=1, address=0x10)
    #0	0x00000001b230a92c in ___lldb_unnamed_symbol1320 ()
    #1	0x00000001b22adf3c in ___lldb_unnamed_symbol909 ()
    #2	0x0000000100003ec0 in main at /Users/cdhw/Downloads/DFTbug/DFTbug/main.c:28
    #3	0x000000010001508c in start ()

I’ve pasted code below for a short command line tool that demonstrates the issue.

A workaround is to use NULL instead of a previous vDSP_DFT_SetupD structure but this has severe speed penalty in practice.



//
//  main.c
//  DFTbug
//
//  Created by Charles Williams on 07/10/2022.
//

#include <stdio.h>
#include <Accelerate/Accelerate.h>

int main(int argc, const char * argv[]) {
    int N = 1024*1024;
    double * out_real = calloc(N,sizeof(double));
    double * out_imag = calloc(N,sizeof(double));
    double * inp_real = calloc(N,sizeof(double));
    double * inp_imag = calloc(N,sizeof(double));

    printf("Starting\n");
    
    vDSP_DFT_SetupD setup_1 = vDSP_DFT_zop_CreateSetupD(NULL, N, vDSP_DFT_INVERSE );
    printf("Setup 1 created\n");
    vDSP_DFT_ExecuteD( setup_1, out_real, out_imag, inp_real, inp_imag);
    printf("Setup 1 executed\n");
    vDSP_DFT_SetupD setup_2 = vDSP_DFT_zop_CreateSetupD(setup_1, N/2, vDSP_DFT_INVERSE );
    printf("Setup 2 created\n");
    vDSP_DFT_DestroySetupD(setup_1);
    printf("Setup 1 destroyed\n");
    vDSP_DFT_ExecuteD( setup_2, out_real, out_imag, inp_real, inp_imag);
    printf("Setup 2 executed\n");
   vDSP_DFT_DestroySetupD(setup_2);
    printf("Setup 2 destroyed\n");

    printf("Finished\n");

    return 0;
}

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!