dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
20.93k stars 4.9k forks source link

process "dotnet" crashes when creating opentk texture (unsafe, fixed ptr) #928

Closed KelsonBall closed 7 years ago

KelsonBall commented 7 years ago

Dotnet crashes when creating texture

I am trying to render an image in dotnet core 2.0 using opentk and imagesharp and ran into a situation where the dotnet process crashes.

Here is the specific snippet where the issue occurs

using System;
using OpenTK.Graphics.OpenGL4;
using ImageSharp;
unsafe
{
    fixed (int* dataptr = &data[0])
    {
        GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, Width, Height, 0, PixelFormat.Bgra, PixelType.Int, (IntPtr)dataptr);                    
    }
}

Here is the resulting windows error box

image

System is windows 10, dotnet installed through visual studio 2017

Debuging gives this exception info

Unhandled exception at 0x00007FFB95563C58 (KernelBase.dll) in dotnet.exe: 0xE0434352 (parameters: 0xFFFFFFFF80070002, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00007FFB5F7D0000). occurred

KelsonBall commented 7 years ago

Memory beyond the array was being accessed (gl parameter PixelType doesnt describe the type of the whole pixel, only the type of each rgba element)