1

I am using a FluorineFx 1.0.0.17 in my project and working with NetConnection to connect to a RTMP host (Flash Media Server). I am creating a RTMP monitoring probe for PRTG.

There is always an error at the end of the main application process on the line 173 of WorkItemsQueue.cs file (second code line shown here)

// Prepare array of wait handle for the WaitHandle.WaitAny()
WaitHandle [] waitHandles = new WaitHandle [] { WaitEntry.WaitHandle, cancelEvent };

// Wait for available resource, cancel event, or timeout.
int index = WaitHandle.WaitAny(waitHandles, millisecondsTimeout, true);

This is what debugger shows me:

enter image description here

Call stack:

[In a sleep, wait, or join] 
[External Code] 
FluorineFx.dll!FluorineFx.Threading.WorkItemsQueue.DequeueWorkItem(int millisecondsTimeout, System.Threading.WaitHandle cancelEvent) Line 173 + 0xd bytes   C#
FluorineFx.dll!FluorineFx.Threading.ThreadPoolEx.Dequeue() Line 329 + 0x2c bytes    C#
FluorineFx.dll!FluorineFx.Threading.ThreadPoolEx.ProcessQueuedItems() Line 378 + 0x8 bytes  C#
[External Code] 
kernel32.dll!749c3677()     
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]  
ntdll.dll!770e9f42()    
ntdll.dll!770e9f15()    

By at the end of the process I mean whole program works as it should, but when at the end of Main method debugger throws this unmanaged-code error (shows only if Enable unmanaged code debugging is enabled).

enter image description here

I have no idea how to debug this, nor how to avoid it. Any help would be appreciated.

UPDATE 1:

enter image description here

Main threads stopps at:

 Environment.Exit(0);
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
mizi_sk
  • 1,007
  • 7
  • 33
  • Btw, your call stack is for the wrong thread. IOW not one throwing the exception. – leppie Mar 20 '12 at 12:57
  • @leppie It is heap corruption. Debugging will not show correct result. – Aliostad Mar 20 '12 at 12:59
  • @Aliostad: Heap corruption is a rather vague 'reason'. (perhaps I am ignorant common from a pure managed world ;p) – leppie Mar 20 '12 at 13:01
  • 1
    @leppie It is access violation, i.e. process attempted to access a memory location not within its memory space. This happens with buffer overruns, ... you name it. – Aliostad Mar 20 '12 at 13:01
  • @Aliostad: Ahh, I see now. Subtle differences in the messages of the same error code. :) – leppie Mar 20 '12 at 13:03
  • @mizi_sk: Try adding a null entry at the end of the array. (just a hunch) – leppie Mar 20 '12 at 13:04
  • @leppie ;) I have done some unmanaged C, C++ and used in .NET and familiar with its pains. – Aliostad Mar 20 '12 at 13:04

1 Answers1

2

Visual studio could be lying to you in case of Multi-Threaded debugging. It is not possible for the waitHandles to be null.

You seem to have a corrupted heap.

Detail

You get access violation when process attempted to access a memory location not within its memory space. This happens with buffer overruns, ... you name it. If you use an unmanaged code, this could easily do it.

Aliostad
  • 80,612
  • 21
  • 160
  • 208
  • What should I do then? How to debug it? I would gladly just hack the error out, as it is after the program ends. – mizi_sk Mar 20 '12 at 12:56
  • Your heap is corrupt. Something in the unmanaged code is corrupting your heap. Finding that out is **not easy**. – Aliostad Mar 20 '12 at 12:58
  • I am using FluorineFx library and my code is like 20 lines. So it seems I should contact FluorineFx support. (I am adding a threads debug screenshot) – mizi_sk Mar 20 '12 at 13:02
  • Yes, I would say if you have paid for it, you do. It might need some cleanup code before it finishes so that is what you are missing. – Aliostad Mar 20 '12 at 13:06
  • Thanks @Aliostad however FluorineFx support is little slow (whole FluorineFx is one man side job as I understand it) so I will look into alternative RTMP C# client libraries. – mizi_sk Mar 20 '12 at 13:10
  • Old good truth says: "Want something done right? Do it yourself." – luke1985 Dec 29 '13 at 13:48