<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic FEAST crashes using C# interop on dotnet 10 in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FEAST-crashes-using-C-interop-on-dotnet-10/m-p/1753099#M37623</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Executing the following FEAST interop code (taken from the C examples) results in a crash on dotnet 10 (no exception is thrown, the program just exits with error code 0xC0000409 STATUS_STACK_BUFFER_OVERRUN). The same code runs fine on .NET framework 4.8.&lt;/P&gt;&lt;P&gt;Can someone confirm this or maybe has an idea, if something is wrong with the interop code?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OS: Windows 11 25H2&lt;/P&gt;&lt;P&gt;Runtime/SDK: dotnet 10 (latest)&lt;/P&gt;&lt;P data-unlink="true"&gt;MKL version:&amp;nbsp;2026.1.0.226&amp;nbsp;(intelmkl.redist.win-x64 from nuget)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;dotnet run -c Debug -f net48   --&amp;gt; OK
dotnet run -c Debug -f net10.0 --&amp;gt; 0xc0000409&lt;/LI-CODE&gt;&lt;P&gt;csproj file:&lt;/P&gt;&lt;LI-CODE lang="xml"&gt;&amp;lt;Project Sdk="Microsoft.NET.Sdk"&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;OutputType&amp;gt;Exe&amp;lt;/OutputType&amp;gt;
    &amp;lt;TargetFrameworks&amp;gt;net10.0;net48&amp;lt;/TargetFrameworks&amp;gt;
    &amp;lt;AllowUnsafeBlocks&amp;gt;True&amp;lt;/AllowUnsafeBlocks&amp;gt;
    &amp;lt;LangVersion&amp;gt;latest&amp;lt;/LangVersion&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
&amp;lt;/Project&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;C# source:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using System.Runtime.InteropServices;

using MKL_INT = System.Int32;

unsafe class Program
{
    public static void Main()
    {
        dfeast_sparse();
    }

    public const string DLL = "mkl_rt.3.dll";

    [DllImport(DLL, EntryPoint = "feastinit", CallingConvention = CallingConvention.Cdecl)]
    public static extern void feastinit(MKL_INT* fpm);

    [DllImport(DLL, EntryPoint = "dfeast_scsrev", CallingConvention = CallingConvention.Cdecl)]
    public static extern void dfeast_scsrev(/*const*/ byte* uplo, /*const*/ MKL_INT* n, /*const*/ double* a, /*const*/ MKL_INT* ia, /*const*/ MKL_INT* ja, MKL_INT* fpm, double* epsout, MKL_INT* loop, /*const*/ double* emin, /*const*/ double* emax, MKL_INT* m0, double* e, double* x, MKL_INT* m, double* res, MKL_INT* info);

    public static void dfeast_sparse()
    {
        byte UPLO = (byte)'F'; /* Type of matrix: (F means full matrix, L/U - lower/upper triangular part of matrix) */
        /* Matrix A of size N in CSR format. Size N and 3 arrays are used to store matrix in CSR format */
        const MKL_INT N = 11;
        MKL_INT[] rows/*[12]*/ = { 1, 5, 10, 16, 23, 30, 37, 44, 51, 57, 62, 66 };
        MKL_INT[] cols/*[65]*/ = {    1,   2,   3,   4,
                                  1,   2,   3,   4,   5,
                                  1,   2,   3,   4,   5,   6,
                                  1,   2,   3,   4,   5,   6,   7,
                                       2,   3,   4,   5,   6,   7,   8,
                                            3,   4,   5,   6,   7,   8,   9,
                                                 4,   5,   6,   7,   8,   9,  10,
                                                      5,   6,   7,   8,   9,  10,  11,
                                                           6,   7,   8,   9,  10,  11,
                                                                7,   8,   9,  10,  11,
                                                                     8,   9,  10,  11
                            };

        double[] val/*[65]*/ = {   5.0, 2.0, 1.0, 1.0,
                                2.0, 6.0, 3.0, 1.0, 1.0,
                                1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                     1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                          1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                               1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                                    1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                                         1.0, 1.0, 3.0, 6.0, 3.0, 1.0,
                                                              1.0, 1.0, 3.0, 6.0, 2.0,
                                                                   1.0, 1.0, 2.0, 5.0
                            };

        /* Matrix B of size N in CSR format. Size N and 3 arrays are used to store matrix in CSR format */
        MKL_INT[] rowsb/*[12]*/ = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
        MKL_INT[] colsb/*[11]*/ = { 1,
                                    2,
                                        3,
                                            4,
                                                5,
                                                    6,
                                                        7,
                                                            8,
                                                                9,
                                                                    10,
                                                                        11
                              };

        double[] valb/*[11]*/ = {  1.0,
                                    1.0,
                                        1.0,
                                            1.0,
                                                1.0,
                                                    1.0,
                                                        1.0,
                                                            1.0,
                                                                1.0,
                                                                    1.0,
                                                                        1.0
                            };

        /* Declaration of FEAST variables */
        MKL_INT[] fpm = new MKL_INT[128];      /* Array to pass parameters to  Intel oneMKL Extended Eigensolvers */
        MKL_INT M_expected = 6; /* Exact number of eigenvalues in the interval [Emin, Emax] */
        double Emin, Emax;    /* Lower/upper bound of search interval [Emin,Emax] */

        double epsout;        /* Relative error on the trace */
        MKL_INT loop;          /* Number of refinement loop */
        MKL_INT L = 8;
        MKL_INT M0;            /* Initial guess for subspace dimension to be used */
        MKL_INT M;             /* Total number of eigenvalues found in the interval */

        double[] E = new double[11];         /* Eigenvalues */
        double[] X = new double[121];        /* Eigenvectors */
        double[] res = new double[11];       /* Residual */

        /* Declaration of local variables */
        MKL_INT info;          /* Errors */
        double[] Eig = new double[6];       /* Eig - array for storing exact eigenvalues */
        double[] R = new double[6];         /* R = |E-Eig| */
        double[] Y = new double[36];        /* Y=(X')*X-I */

        MKL_INT i;
        double eigabs;

        /* Exact eigenvalues in range (3.0, 7.0) */
        Eig[0] = 3.1715728752538100;
        Eig[1] = 4.0000000000000000;
        Eig[2] = 4.0000000000000000;
        Eig[3] = 4.1292484841890931;
        Eig[4] = 4.4066499006731521;
        Eig[5] = 6.0000000000000000;

        Console.WriteLine("\n FEAST DFEAST_SCSREV AND DFEAST_SCSRGV EXAMPLE");
        Console.WriteLine("Sparse matrix size " + N);

        /* Search interval [Emin,Emax] */
        Emin = 3.0;
        Emax = 7.0;
        Console.WriteLine("Search interval [ {0}, {1}  ]  ", Emin, Emax);

        M0 = L;
        M = L;
        loop = 0;
        info = 0;
        epsout = 0.0;

        /* Step 1. Call  FEASTINIT to define the default values for the input FEAST parameters */
        fixed (MKL_INT* _fpm = fpm)
        {
            feastinit(
                _fpm /* OUT: Array is used to pass parameters to  Intel oneMKL Extended Eigensolvers */
                );
        }

        fpm[0] = 1; /* Extended Eigensolver routines print runtime status to the screen. */
        int _N = N;
        /* Step 2. Solve the standard Ax = ex eigenvalue problem. */
        Console.WriteLine("Testing dfeast_scsrev routine:");

        fixed (double* _val = val)
        fixed (MKL_INT* _rows = rows)
        fixed (MKL_INT* _cols = cols)
        fixed (MKL_INT* _fpm = fpm)
        fixed (double* _E = E)
        fixed (double* _X = X)
        fixed (double* _res = res)
        {
            dfeast_scsrev(
                &amp;amp;UPLO,   /* IN: UPLO = 'F', stores the full matrix */
                &amp;amp;_N,      /* IN: Size of the problem */
                _val,     /* IN: CSR matrix A, values of non-zero elements */
                _rows,    /* IN: CSR matrix A, index of the first non-zero element in row */
                _cols,    /* IN: CSR matrix A, columns indices for each non-zero element */
                _fpm,     /* IN/OUT: Array is used to pass parameters to  Intel oneMKL Extended Eigensolvers */
                &amp;amp;epsout, /* OUT: Relative error of on the trace */
                &amp;amp;loop,   /* OUT: Contains the number of refinement loop executed */
                &amp;amp;Emin,   /* IN: Lower bound of search interval */
                &amp;amp;Emax,   /* IN: Upper bound of search interval */
                &amp;amp;M0,     /* IN: The initial guess for subspace dimension to be used. */
                _E,       /* OUT: The first M entries of Eigenvalues */
                _X,       /* IN/OUT: The first M entries of Eigenvectors */
                &amp;amp;M,      /* OUT: The total number of eigenvalues found in the interval */
                _res,     /* OUT: The first M components contain the relative residual vector */
                &amp;amp;info    /* OUT: Error code */
                );
        }

        Console.WriteLine("FEAST OUTPUT INFO " + info);
        if (info != 0)
        {
            Console.WriteLine(" dfeast_scsrev returns code of ERROR: " + info);
            return;
        }
        else if (M != M_expected)
        {
            Console.WriteLine(" dfeast_scsrev returns wrong number of eigenvalues ");
            return;
        }

        /* Step 3. Compute the residual R(i) = | E(i) - Eig(i) |  where Eig(i)
        * are the expected eigenvalues and E(i) are eigenvalues computed by DFEAST_SCSREV(). */
        Console.WriteLine("Number of eigenvalues found " + M);
        Console.WriteLine("Computed      |    Expected    ");
        Console.WriteLine("Eigenvalues   |    Eigenvalues ");
        eigabs = 0.0;
        for (i = 0; i &amp;lt; M; i++)
        {
            R[i] = Math.Abs(E[i] - Eig[i]);
            eigabs = Math.Max(eigabs, R[i]);
            Console.WriteLine("{0} {1} ", E[i], Eig[i]);
        }
        Console.WriteLine("Max value of | computed eigenvalue - expected eigenvalues | " + eigabs);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 04 Jul 2026 17:17:38 GMT</pubDate>
    <dc:creator>chrwo</dc:creator>
    <dc:date>2026-07-04T17:17:38Z</dc:date>
    <item>
      <title>FEAST crashes using C# interop on dotnet 10</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FEAST-crashes-using-C-interop-on-dotnet-10/m-p/1753099#M37623</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Executing the following FEAST interop code (taken from the C examples) results in a crash on dotnet 10 (no exception is thrown, the program just exits with error code 0xC0000409 STATUS_STACK_BUFFER_OVERRUN). The same code runs fine on .NET framework 4.8.&lt;/P&gt;&lt;P&gt;Can someone confirm this or maybe has an idea, if something is wrong with the interop code?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OS: Windows 11 25H2&lt;/P&gt;&lt;P&gt;Runtime/SDK: dotnet 10 (latest)&lt;/P&gt;&lt;P data-unlink="true"&gt;MKL version:&amp;nbsp;2026.1.0.226&amp;nbsp;(intelmkl.redist.win-x64 from nuget)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;dotnet run -c Debug -f net48   --&amp;gt; OK
dotnet run -c Debug -f net10.0 --&amp;gt; 0xc0000409&lt;/LI-CODE&gt;&lt;P&gt;csproj file:&lt;/P&gt;&lt;LI-CODE lang="xml"&gt;&amp;lt;Project Sdk="Microsoft.NET.Sdk"&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;OutputType&amp;gt;Exe&amp;lt;/OutputType&amp;gt;
    &amp;lt;TargetFrameworks&amp;gt;net10.0;net48&amp;lt;/TargetFrameworks&amp;gt;
    &amp;lt;AllowUnsafeBlocks&amp;gt;True&amp;lt;/AllowUnsafeBlocks&amp;gt;
    &amp;lt;LangVersion&amp;gt;latest&amp;lt;/LangVersion&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
&amp;lt;/Project&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;C# source:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using System.Runtime.InteropServices;

using MKL_INT = System.Int32;

unsafe class Program
{
    public static void Main()
    {
        dfeast_sparse();
    }

    public const string DLL = "mkl_rt.3.dll";

    [DllImport(DLL, EntryPoint = "feastinit", CallingConvention = CallingConvention.Cdecl)]
    public static extern void feastinit(MKL_INT* fpm);

    [DllImport(DLL, EntryPoint = "dfeast_scsrev", CallingConvention = CallingConvention.Cdecl)]
    public static extern void dfeast_scsrev(/*const*/ byte* uplo, /*const*/ MKL_INT* n, /*const*/ double* a, /*const*/ MKL_INT* ia, /*const*/ MKL_INT* ja, MKL_INT* fpm, double* epsout, MKL_INT* loop, /*const*/ double* emin, /*const*/ double* emax, MKL_INT* m0, double* e, double* x, MKL_INT* m, double* res, MKL_INT* info);

    public static void dfeast_sparse()
    {
        byte UPLO = (byte)'F'; /* Type of matrix: (F means full matrix, L/U - lower/upper triangular part of matrix) */
        /* Matrix A of size N in CSR format. Size N and 3 arrays are used to store matrix in CSR format */
        const MKL_INT N = 11;
        MKL_INT[] rows/*[12]*/ = { 1, 5, 10, 16, 23, 30, 37, 44, 51, 57, 62, 66 };
        MKL_INT[] cols/*[65]*/ = {    1,   2,   3,   4,
                                  1,   2,   3,   4,   5,
                                  1,   2,   3,   4,   5,   6,
                                  1,   2,   3,   4,   5,   6,   7,
                                       2,   3,   4,   5,   6,   7,   8,
                                            3,   4,   5,   6,   7,   8,   9,
                                                 4,   5,   6,   7,   8,   9,  10,
                                                      5,   6,   7,   8,   9,  10,  11,
                                                           6,   7,   8,   9,  10,  11,
                                                                7,   8,   9,  10,  11,
                                                                     8,   9,  10,  11
                            };

        double[] val/*[65]*/ = {   5.0, 2.0, 1.0, 1.0,
                                2.0, 6.0, 3.0, 1.0, 1.0,
                                1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                     1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                          1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                               1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                                    1.0, 1.0, 3.0, 6.0, 3.0, 1.0, 1.0,
                                                         1.0, 1.0, 3.0, 6.0, 3.0, 1.0,
                                                              1.0, 1.0, 3.0, 6.0, 2.0,
                                                                   1.0, 1.0, 2.0, 5.0
                            };

        /* Matrix B of size N in CSR format. Size N and 3 arrays are used to store matrix in CSR format */
        MKL_INT[] rowsb/*[12]*/ = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
        MKL_INT[] colsb/*[11]*/ = { 1,
                                    2,
                                        3,
                                            4,
                                                5,
                                                    6,
                                                        7,
                                                            8,
                                                                9,
                                                                    10,
                                                                        11
                              };

        double[] valb/*[11]*/ = {  1.0,
                                    1.0,
                                        1.0,
                                            1.0,
                                                1.0,
                                                    1.0,
                                                        1.0,
                                                            1.0,
                                                                1.0,
                                                                    1.0,
                                                                        1.0
                            };

        /* Declaration of FEAST variables */
        MKL_INT[] fpm = new MKL_INT[128];      /* Array to pass parameters to  Intel oneMKL Extended Eigensolvers */
        MKL_INT M_expected = 6; /* Exact number of eigenvalues in the interval [Emin, Emax] */
        double Emin, Emax;    /* Lower/upper bound of search interval [Emin,Emax] */

        double epsout;        /* Relative error on the trace */
        MKL_INT loop;          /* Number of refinement loop */
        MKL_INT L = 8;
        MKL_INT M0;            /* Initial guess for subspace dimension to be used */
        MKL_INT M;             /* Total number of eigenvalues found in the interval */

        double[] E = new double[11];         /* Eigenvalues */
        double[] X = new double[121];        /* Eigenvectors */
        double[] res = new double[11];       /* Residual */

        /* Declaration of local variables */
        MKL_INT info;          /* Errors */
        double[] Eig = new double[6];       /* Eig - array for storing exact eigenvalues */
        double[] R = new double[6];         /* R = |E-Eig| */
        double[] Y = new double[36];        /* Y=(X')*X-I */

        MKL_INT i;
        double eigabs;

        /* Exact eigenvalues in range (3.0, 7.0) */
        Eig[0] = 3.1715728752538100;
        Eig[1] = 4.0000000000000000;
        Eig[2] = 4.0000000000000000;
        Eig[3] = 4.1292484841890931;
        Eig[4] = 4.4066499006731521;
        Eig[5] = 6.0000000000000000;

        Console.WriteLine("\n FEAST DFEAST_SCSREV AND DFEAST_SCSRGV EXAMPLE");
        Console.WriteLine("Sparse matrix size " + N);

        /* Search interval [Emin,Emax] */
        Emin = 3.0;
        Emax = 7.0;
        Console.WriteLine("Search interval [ {0}, {1}  ]  ", Emin, Emax);

        M0 = L;
        M = L;
        loop = 0;
        info = 0;
        epsout = 0.0;

        /* Step 1. Call  FEASTINIT to define the default values for the input FEAST parameters */
        fixed (MKL_INT* _fpm = fpm)
        {
            feastinit(
                _fpm /* OUT: Array is used to pass parameters to  Intel oneMKL Extended Eigensolvers */
                );
        }

        fpm[0] = 1; /* Extended Eigensolver routines print runtime status to the screen. */
        int _N = N;
        /* Step 2. Solve the standard Ax = ex eigenvalue problem. */
        Console.WriteLine("Testing dfeast_scsrev routine:");

        fixed (double* _val = val)
        fixed (MKL_INT* _rows = rows)
        fixed (MKL_INT* _cols = cols)
        fixed (MKL_INT* _fpm = fpm)
        fixed (double* _E = E)
        fixed (double* _X = X)
        fixed (double* _res = res)
        {
            dfeast_scsrev(
                &amp;amp;UPLO,   /* IN: UPLO = 'F', stores the full matrix */
                &amp;amp;_N,      /* IN: Size of the problem */
                _val,     /* IN: CSR matrix A, values of non-zero elements */
                _rows,    /* IN: CSR matrix A, index of the first non-zero element in row */
                _cols,    /* IN: CSR matrix A, columns indices for each non-zero element */
                _fpm,     /* IN/OUT: Array is used to pass parameters to  Intel oneMKL Extended Eigensolvers */
                &amp;amp;epsout, /* OUT: Relative error of on the trace */
                &amp;amp;loop,   /* OUT: Contains the number of refinement loop executed */
                &amp;amp;Emin,   /* IN: Lower bound of search interval */
                &amp;amp;Emax,   /* IN: Upper bound of search interval */
                &amp;amp;M0,     /* IN: The initial guess for subspace dimension to be used. */
                _E,       /* OUT: The first M entries of Eigenvalues */
                _X,       /* IN/OUT: The first M entries of Eigenvectors */
                &amp;amp;M,      /* OUT: The total number of eigenvalues found in the interval */
                _res,     /* OUT: The first M components contain the relative residual vector */
                &amp;amp;info    /* OUT: Error code */
                );
        }

        Console.WriteLine("FEAST OUTPUT INFO " + info);
        if (info != 0)
        {
            Console.WriteLine(" dfeast_scsrev returns code of ERROR: " + info);
            return;
        }
        else if (M != M_expected)
        {
            Console.WriteLine(" dfeast_scsrev returns wrong number of eigenvalues ");
            return;
        }

        /* Step 3. Compute the residual R(i) = | E(i) - Eig(i) |  where Eig(i)
        * are the expected eigenvalues and E(i) are eigenvalues computed by DFEAST_SCSREV(). */
        Console.WriteLine("Number of eigenvalues found " + M);
        Console.WriteLine("Computed      |    Expected    ");
        Console.WriteLine("Eigenvalues   |    Eigenvalues ");
        eigabs = 0.0;
        for (i = 0; i &amp;lt; M; i++)
        {
            R[i] = Math.Abs(E[i] - Eig[i]);
            eigabs = Math.Max(eigabs, R[i]);
            Console.WriteLine("{0} {1} ", E[i], Eig[i]);
        }
        Console.WriteLine("Max value of | computed eigenvalue - expected eigenvalues | " + eigabs);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jul 2026 17:17:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FEAST-crashes-using-C-interop-on-dotnet-10/m-p/1753099#M37623</guid>
      <dc:creator>chrwo</dc:creator>
      <dc:date>2026-07-04T17:17:38Z</dc:date>
    </item>
  </channel>
</rss>

