Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory_Heap_Corruption when opening MP3 files #636

Open
3 tasks done
StrikingPopcorn opened this issue Nov 26, 2022 · 0 comments
Open
3 tasks done

Memory_Heap_Corruption when opening MP3 files #636

StrikingPopcorn opened this issue Nov 26, 2022 · 0 comments

Comments

@StrikingPopcorn
Copy link

StrikingPopcorn commented Nov 26, 2022

Issue Title (Memory_Heap_Corruption when opening MP3 files)

Hello,
I have the problem that when I open MP3 files the program crashes with a Memory_Heap_Corruption (0xc0000374) and very rarely
with a MemoryAccessViolation. The error occurs exclusively with MP3s but occurs randomly, sometimes I can open several MP3s in a
row and other times it crashes on the first one, making reproduction extremely difficult. I also tried using the LegacyAudioOut but it
didn't help. The Code has a lot of stuff in it specific to my program, so I don't know how much of problem that is going to be.

Issue Categories

  • Bug
  • Not sure

Version Information

  • NuGet Package 4.4.350

Steps to Reproduce

--

Expected Results

  • Plays the MP3 file
  • Doesn't crash

Sample Code

XAML

<MainWindow>
  <StackPanel Grid.Column="6" Grid.Row="0" Grid.RowSpan="3" Background="#2f2633" Grid.ColumnSpan="2">
          <ffme:MediaElement x:Name="me" LoadedBehavior="Play" UnloadedBehavior="Stop" Stretch="None" Height="0"  
            Width="0"/>
   </StackPanel>
</MainWindow>

C# Opening the file

private async void Play_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            foreach (Window window in Application.Current.Windows)
            {
                if (window.GetType() == typeof(MainWindow))
                {
                    if ((window as MainWindow).selectedfilepath != null)
                    {
                        if ((window as MainWindow).playstate != 1 & (window as MainWindow).playstate != 2)
                        {
                            if (Unosquare.FFME.Library.IsInitialized == true)
                            {
                                await (window as MainWindow).me.Open(new Uri((window as MainWindow).selectedfilepath));
                                (window as MainWindow).playstate = 1;
                            }
                            else
                            {
                                string error = "Could not Initialize ffmpeg binaries!";
                                string caption = "Error 0x1";
                                MessageBoxButton button = MessageBoxButton.OK;
                                MessageBoxImage image = MessageBoxImage.Error;
                                MessageBoxResult result;

                                result = MessageBox.Show(error, caption, button, image);

                                switch (result)
                                {
                                    case MessageBoxResult.OK:
                                        Process.GetCurrentProcess().Kill();
                                        break;
                                }
                            }

                        }
                        else if ((window as MainWindow).playstate == 2)
                        {
                            await (window as MainWindow).me.Play();
                            (window as MainWindow).playstate = 1;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }
        }

C# getting the filepath

private void AllTracksDG_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            string filepath = "";
            var index = AllTracksDG.SelectedCells[8];
            string content = (index.Column.GetCellContent(index.Item) as TextBlock).Text;
            SQLiteCommand command = sqlite_conn.CreateCommand();
            command.Parameters.Add(new SQLiteParameter("@Param1", content));
            command.CommandText = "SELECT FilePath FROM Library WHERE FilePath=(@Param1)";
            var reader = command.ExecuteReader();
            while (reader.Read())
            {
                filepath = reader.GetString(0);
            }
            command.Reset();

            var file = ShellFile.FromFilePath(filepath);

            string trackname = file.Properties.System.Title.Value;
            if (trackname != null && trackname.Length > 0)
            {
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).Trackname.Content = trackname;
                    }
                }
            }
            else if (trackname == null)
            {
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).Trackname.Content = null;
                    }
                }
            }
            FileStream fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read);
            fileStream.Seek(0, SeekOrigin.Begin);
            SimpleFile file1 = new SimpleFile(filepath, fileStream);
            SimpleFileAbstraction file2 = new SimpleFileAbstraction(file1);
            var filename = TagLib.File.Create(file2);
            if (filename.Tag.Performers.LongLength > 0)
            {
                string performer = filename.Tag.Performers[0];
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).Artistname.Content = performer;
                    }
                }
            }
            else
            {
                        foreach (Window window in Application.Current.Windows)
                        {
                            if (window.GetType() == typeof(MainWindow))
                            {
                                (window as MainWindow).Artistname.Content = null;
                            }
                        }
            }


            if (filename.Tag.Pictures.Length >= 1)
            {
                TagLib.IPicture pic = filename.Tag.Pictures[0];
                MemoryStream ms = new MemoryStream(pic.Data.Data);
                ms.Seek(0, SeekOrigin.Begin);

                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.StreamSource = ms;
                bitmap.EndInit();

                        foreach (Window window in Application.Current.Windows)
                        {
                            if (window.GetType() == typeof(MainWindow))
                            {
                                (window as MainWindow).Trackimage.Source = bitmap;
                            }
                        }
                        
            }
            else
            {
                        foreach (Window window in Application.Current.Windows)
                        {
                            if (window.GetType() == typeof(MainWindow))
                            {
                                (window as MainWindow).Trackimage.Source = null;
                            }
                        }
            }
            var contenttype = new Mime();
            string type = contenttype.Lookup(filepath);
            if (type.StartsWith("audio"))
            {
                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).selectedfilepath = filepath;
                        
                    }
                }
            }

        }
    }

Command line ffplay

C:\ffmpeg\bin\x64>ffplay "F:\Projects\Aresial-Audio_important files\TestLibrary\Need For Speed Underground 2 (Exclusive 2004) - Soundtrack [www.torrentazos.com]\01 - Snoop Dogg feat. The Doors - Riders on the Storm (Fredwreck Remix) - www.torrentazos.com.mp3"
ffplay version 5.1.1-full_build-www.gyan.dev Copyright (c) 2003-2022 the FFmpeg developers
  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-shared --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[mp3 @ 0000025805e5bdc0] Skipping 626 bytes of junk at 12227.=0/0
[mp3 @ 0000025805e5bdc0] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'F:\Projects\Aresial-Audio_important files\TestLibrary\Need For Speed Underground 2 (Exclusive 2004) - Soundtrack [www.torrentazos.com]\01 - Snoop Dogg feat. The Doors - Riders on the Storm (Fredwreck Remix) - www.torrentazos.com.mp3':
  Metadata:
    album           : Need For Speed™ Underground 2
    copyright       : © 2004 Electronic Arts Inc.
    track           : 1/28
    album_artist    : EA Games Soundtrack
    title           : Riders on the Storm (Fredwreck
    artist          : Snoop Dogg feat. The Doors
    comment         : www.torrentazos.com
    genre           : Soundtrack
    date            : 2004
  Duration: 00:06:15.91, start: 0.000000, bitrate: 192 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s
  Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 170x170 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)
    Metadata:
      comment         : Cover (front)
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c371200] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c385a00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c39b600] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3b0880] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3cab40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3dde40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3f3400] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4109c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c41e980] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c435bc0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4466c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c45d900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c47a900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4109c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4466c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c41e980] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c47a900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c431b80] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3dc700] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3ed6c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c371200] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3821c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c38f1c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3a2180] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3bf180] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3cc180] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c39e180] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3bf180] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3cc180] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c46e8c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c371200] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c37e1c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c38f1c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3e2700] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3f7700] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4046c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4176c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4386c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c445680] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4136c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4386c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c445680] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c46e8c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c47b8c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3dc700] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3e96c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c4006c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c375200] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c383d40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3972c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3b42c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000025805ebffc0] [swscaler @ 000002580c3c12c0] deprecated pixel format used, make sure you did set range correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant