- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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.
Can someone confirm this or maybe has an idea, if something is wrong with the interop code?
Regards,
Chris
OS: Windows 11 25H2
Runtime/SDK: dotnet 10 (latest)
MKL version: 2026.1.0.226 (intelmkl.redist.win-x64 from nuget)
dotnet run -c Debug -f net48 --> OK
dotnet run -c Debug -f net10.0 --> 0xc0000409csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net10.0;net48</TargetFrameworks>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>C# source:
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(
&UPLO, /* IN: UPLO = 'F', stores the full matrix */
&_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 */
&epsout, /* OUT: Relative error of on the trace */
&loop, /* OUT: Contains the number of refinement loop executed */
&Emin, /* IN: Lower bound of search interval */
&Emax, /* IN: Upper bound of search interval */
&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 */
&M, /* OUT: The total number of eigenvalues found in the interval */
_res, /* OUT: The first M components contain the relative residual vector */
&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 < 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);
}
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both for reporting this issue!
It is related to the changes in oneMKL 2025.2 and stricter security settings (control flow guard) in .NET 10 comparing to .NET 4.8. I can reproduce the crash with oneMKL 2026.1 with /guard:cf in a pure C code which is translated from the shared example.
We had related known issues back in the 2025.2 release, but it seems it has wider impact. I will report this as a bug internally.
Thanks,
Fengrui
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your time and interest. Keep up the good work!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page