View Full Version : CAVIStreamSynth: System exception - Access Violation at ...
stax76
9th May 2015, 16:15
I'm calling a function named SMDegrain() in StaxRip x64 using avifile API, when I load the same script in VirtualDub x64 I don't see this problem.
Does VirtualDub x64 interface with AviSynth via avifile API or like most applications directly?
How can I find out which module is causing this exception and in particular where in the source code. I've not really experience with native coding so could use some hints, there are issues with nnedi3 and DGDecNV and it all might relate, I'm sure I can get to the bottom of this, question is only how long will it take...
Groucho2004
9th May 2015, 16:48
When you search the forum for "CAVIStreamSynth" it seems that several people had problems with exceptions/access violations.
Maybe it's time to start using the native Avisynth interface. If you can't implement that in Basic there is possibly code for a wrapper somewhere.
As far as I know, VirtualDub uses it's own wrapper involving AVIFile API, have a look at the source.
stax76
9th May 2015, 17:07
I could replace my complete interface probably in less then 3 hours, I doubt it would help however but I can search for a existing app or make a small sample app, should be fairly easy.
videoh
9th May 2015, 17:25
I've not really experience with native coding so could use some hints, there are issues with nnedi3 and DGDecNV and it all might relate There are no problems with DGDecNV 64-bit. The problem is in your application.
Maybe it's time to start using the native Avisynth interface. Amen, bro.
stax76
9th May 2015, 18:03
How would you know the bug is in my code? Years ago when MediaInfo crashed StaxRip but not VirtualDub the bug wasn't in StaxRip. Actually I have a theory and I could search or ask about the technical background, my theory is there is a bad pointer trying to access managed memory, it might as well be my code, the thing is nobody knows anything at this point and asking for samples, scripts and VirtualDub simply does not help, for debugging you need:
Win8/Win10 x64
AviSynth+ x64
.NET AviSynth client x64 using avifile API
Within in hour I could find out if MeGUIs completely different interop layer yields also to this problem, it's only like 50 lines code, even if it succeeds the bug is still unknown, why do 15 plugins work and only 2 don't, isn't this a indication there might be something wrong with this 2 plugins? I work since 15 years on StaxRip and have at least done a couple small C++ applications and some of these C++ applications where using different interop techniques, C, COM+, I've even written a C++/CLR application so I have some C++ and native/managed interop knowledge. You are hardly qualified to tell me where the bug is if you've not done native/managed interop.
videoh
9th May 2015, 18:47
the thing is nobody knows anything at this point Au contraire. We know that DGDecNV works flawlessly with the major applications and no crashes have been reported for a long time. So the prior probability of there being a problem in DGDecNV is extremely low compared to your brand new StaxRip 64-bit implementation. DGDecodeNV is a simple DLL and contains no "pointers into managed space". And you still haven't actually told us what problem you have with DGDecNV. Is it so unreasonable to ask about it?
If you have an access violation did you do some code stepping through your app to see when it occurs? That seems to me to be the obvious place to start. Also, how are you invoking Avisynth? Can you show us your code for that?
stax76
9th May 2015, 18:50
What is so difficult to understand that the only thing you need is a x64 .NET client and what is so difficult to understand that the fact that the bug surfaces only with a .NET client doesn't necessarily mean the bug is in the .NET client?
videoh
9th May 2015, 19:13
I understand perfectly.
I asked you some questions to try to help you. Do you want to answer them? Here are the questions again:
Exactly what problem do you have with DGDecNV 64-bit? Do you have a crash dump to show us or something similar?
If you have an access violation did you do some code stepping through your app to see when it occurs? That seems to me to be the obvious place to start.
Also, how are you invoking Avisynth? Can you show us your code for that?
Groucho2004
9th May 2015, 21:13
I've not really experience with native coding so could use some hints
avs2yuv (http://avisynth.nl/index.php/Filter_SDK/avs2yuv) is a nice example. Apart from that, the Development section (http://avisynth.nl/index.php/Main_Page#Development) on avisynth.nl has lots of info.
stax76
9th May 2015, 21:16
Exactly what problem do you have with DGDecNV 64-bit? Do you have a crash dump to show us or something similar?
You and DG did hardly read or understand or did not want to understand what I wrote at his board, the problem happens with any media and any script, it happens not with VirtualDub but with StaxRip. It took me a few minutes since I'm clumsy with curly braces but here is a sample application with code with MeGUIs interop layer:
http://www.mediafire.com/download/1j3ycqyn5wb281p/avs.7z
the layer is completely different interfacing with AviSynth directly with a native wrapper library and not using avifile API. avifile API might be old but it works perfectly, is blazing fast and requires 5 times less code and no wrapper library. My experience told me it won't help and MPC crashes as well and I verified with ProcessExplorer the CLR isn't loaded into MPC process space by a shell extension or something.
Exactly what problem do you have with DGDecNV 64-bit? Do you have a crash dump to show us or something similar?
It crashes and it's ridiculous easy to reproduce with 2 sample applications I made with 2 different interop layers, it's of course much easier to say my interop code is flawed. I do not have a crash dump because I never had to debug with such a technique, I already asked to guide me with this.
If you have an access violation did you do some code stepping through your app to see when it occurs? That seems to me to be the obvious place to start.
I already tried everything obvious, AviSynth returns a error message which I handle, after this sometimes a native crash happens.
Also, how are you invoking Avisynth? Can you show us your code for that?
I posted it in a code tag at DGs forum and also uploaded a sample application with code, nobody tried to understand what I wrote there so I just left.
stax76
9th May 2015, 21:28
here is the avifile sample application and code I posted at DGs board:
http://www.mediafire.com/download/tr2u393aejhib06/WindowsApplication1.7z
videoh
9th May 2015, 21:57
AviSynth returns a error message which I handle, after this sometimes a native crash happens What are you doing in your code that returns the error message, and what is the error message and how do you handle it?
Some people may not want to install a .NET development environment and then build and debug your application to help with interfacing properly to Avisynth.
stax76
9th May 2015, 22:32
With DGDecNV I get the error message:
System exception - Access Violation
(D:\Temp\test temp files\test.avs, line 2)
LoadPlugin("D:\Software\Medien\DGDecNV\DGDecodeNV.dll")
DGSource("D:\Temp\test temp files\test.dgi")
both sample applications and MPC-BE show this error, the only plugins with this problem is DGDecNV and nnedi3, nnedi3 work with opt=1 disabling asm, on Win7 everything works if I remember right, before this mess started I was on Win7, now I'm on Win10, I had a few pointer related bugs in my interop code that surfaced only on Win8/Win10 so I migrated to Win10.
videoh
9th May 2015, 22:36
Are you able to run your code in the VB .NET debugger? If so, you can break on the access violation and see what's going on. Just start debugging and make the error happen. When you get the access violation popup, tell it to break. You will be right at the call to the faulting module, can see who called it, etc.
You can get crash dumps various ways. Dr Watson is one popular choice.
captainadamo
10th May 2015, 00:58
Another way is to use Task Manager as long as the process is still running when you get the error message popup. You can right click the process and tell it create a crash dump.
stax76
10th May 2015, 01:07
It's always terminating after a few seconds, I got some clues now however.
captainadamo
10th May 2015, 01:10
What I mean is if you get the access violation popup message don't close it and then you can use task manager to create a crash dump. Obviously if you close the popup the process will terminate.
videoh
10th May 2015, 01:12
He's got clues now but won't tell us what they are. :confused:
He also won't answer simple, direct questions, such as "Are you able to run your code in the VB .NET debugger?"
stax76
10th May 2015, 01:27
I was debugging nnedi3 and I know the line causing the access violation, first I thought my crop dialog works so I thought there is something in my code but I forgot that the crop dialog uses only the source filter so it did not use nnedi3 or DGindexNV. DG can download both super simple test projects for visual studio and debug his code, it's not my problem any longer.
videoh
10th May 2015, 01:34
I was debugging nnedi3 and I know the line causing the access violation But you won't tell us what line that is. Anyway, we are talking about DGDecode, not nnedi3. Do you think nnedi3 calls code in dgdecodenv.dll?
If you give Graft a simple C++ based project I'm sure he will be able to help you. But if you give him VB .NET + avifile + "reflection hack", he is not going to be interested, and you'll have to debug that stuff yourself.
foxyshadis
10th May 2015, 05:19
I was debugging nnedi3 and I know the line causing the access violation, first I thought my crop dialog works so I thought there is something in my code but I forgot that the crop dialog uses only the source filter so it did not use nnedi3 or DGindexNV. DG can download both super simple test projects for visual studio and debug his code, it's not my problem any longer.
There's literally no way that the line you found could naturally result in an access violation: The only things accessed are primitive ints, not pointers. That points to a corrupt stack, which means something is scribbling all over memory, if the line pointed to is even the real error. I think it might be a good idea to study C++ debugging techniques if you really want to pursue this; Raymond Chen's blog (The Old New Thing) and StackOverflow are great resources. Apart from that, I'd like to help, but I only have a few minutes here and there online these days.
You guys need to follow this thread as well (https://forum.doom9.org/showthread.php?p=1720899#post1720899) to see the full discussion.
manolito
10th May 2015, 08:39
@ videoh
I'm following this thread just out of interest (can't use the latest StaxRip since Stax has abandoned us poor XP users...).
But I really find it a little irritating if you continue speaking about "Graft" in the third person. Everybody here knows by now that videoh == neuron2 == Guest == Donald Graft. Could you please stop this ridiculous disguise?
Cheers
manolito
stax76
10th May 2015, 10:41
There's literally no way that the line you found could naturally result in an access violation: The only things accessed are primitive ints, not pointers. That points to a corrupt stack, which means something is scribbling all over memory, if the line pointed to is even the real error. I think it might be a good idea to study C++ debugging techniques if you really want to pursue this; Raymond Chen's blog (The Old New Thing) and StackOverflow are great resources. Apart from that, I'd like to help, but I only have a few minutes here and there online these days.
You guys need to follow this thread as well (https://forum.doom9.org/showthread.php?p=1720899#post1720899) to see the full discussion.
Thanks, I want to learn more C++ and also Rust, I have a feature in StaxRip I coded with help of one of Chen's articles, it shows windows explorer but also selects a file. It involves using automation interfaces (IDispatch), such interfaces where made for VBScript, VB6 and VBA, using it from C++ is a lot more work compared to a language like VB.NET which has inherited late binding support from VB6. StaxRip originated 2001 as simple VBScript, was then migrated to VB6 and when .NET came out 2001 it was migrated to VB.NET. Because everybody hated .NET I had a fight with Koepi, this thread is my second fight on Doom9 again because of adopting something early.
My code based on this article is the only place I use Late Binding, in other places I use reflection working with IDispatch if it's simple enough. I used refection quite often for hacking private .NET features, when a hack with 3 lines code gives me the same result which would otherwise require dozens or hundreds lines of code then I'm all in. avifile API returns a DIB which I convert to a .NET Bitmap by accessing private parts of the Bitmap class using reflection. Other then hacking and automation reflection is a great tool for many other things making .NET a productive environment.
The automation code for explorer also had the most common x64 bug my code had, it was calling IntPtr.ToInt32 which on x86 was working fine of course but on x64 was failing, the nasty thing was it was mostly crashing only on Win8/Win10 and still worked fine most of the time on Win7, DGDecNV also works fine on Win7 with StaxRip x64 but not on Win10, it still could be my code, it's just unlikely considering it happens only with 2 plugins, not on Win7 and also with unmanaged MPC and with MeGUIs different interop code.
I respected neuron2 always as C++ programming expert but with his total ignorance towards .NET most of the respect is lost.
http://blogs.msdn.com/b/oldnewthing/archive/2004/07/20/188696.aspx
Option Strict Off
Imports Microsoft.VisualBasic
Public Class Explorer
Shared ShellApp As Object = CreateObject("Shell.Application")
Shared Sub SelectFile(handle As IntPtr, filepath As String)
For Each i In ShellApp.Windows
Dim h = If(Environment.Is64BitOperatingSystem, handle.ToInt64, handle.ToInt32)
If TypeName(i) = "IWebBrowser2" AndAlso i.HWND = h Then
'two shorter methods tried to get correct FolderItem but didn't work
For Each i2 In i.Document.Folder.Items()
If i2.Path = filepath Then
i.Document.SelectItem(i2, 1 + 4 + 8)
Exit Sub
End If
Next
End If
Next
End Sub
End Class
Groucho2004
10th May 2015, 12:22
I respected neuron2 always as C++ programming expert but with his total ignorance towards .NET most of the respect is lost.
Ignoring .NET is a choice. Disrespecting someone for that choice is ridiculous and ignorant.
I found this text about .NET programming and found it very fitting:
Programming with .NET is like cooking in a McDonalds kitchen. It is full of amazing tools that automate absolutely everything. Just press the right button and follow the beeping lights, and you can churn out flawless 1.6 oz burgers faster than anybody else on the planet.
However, if you need to make a 1.7 oz burger, you simply can’t. There’s no button for it. The patties are pre-formed in the wrong size. They start out frozen so they can’t be smushed up and reformed, and the thawing machine is so tightly integrated with the cooking machine that there’s no way to intercept it between the two. A McDonalds kitchen makes exactly what’s on the McDonalds menu - and does so in an absolutely foolproof fashion. But it can’t go off the menu, and any attempt to bend the machine to your will just breaks it such that it needs to be sent back to the factory for repairs.
sh0dan
10th May 2015, 15:39
Guys, please keep the tone sober. There is no need to go into personal assaults and name calling. This goes for manolito, stax and maybe others I have missed.
Be aware that not all people are native English speakers, and therefore writing things that may seem innocent to you may seem offensive to others. So tone the personal stuff down, and try to keep to the subject.
stax76
10th May 2015, 16:32
http://oi58.tinypic.com/243i2vq.jpg
videoh
10th May 2015, 16:37
OK, thank you, but that does not show a crash in my filter code. Line 2 of the AVS script kicks off a lot of things and just because Avisynth points to that script line, it doesn't mean it faulted in my code. It could still be something like improper interfacing to Avisynth.
Also, that is not the MPC-BE screenshot that I asked for in the other thread.
Can you please provide a proper crash dump? You've been given two ways to get it and it's really easy. It would help me to address your problem and would certainly motivate me if it shows a crash in my code. Thank you.
stax76
10th May 2015, 16:52
It could still be something like improper interfacing to Avisynth.
improper interfacing to Avisynth is unlikely because 3 different interfaces were tested:
StaxRip avifle interface, very simple, robust and fast
MeGUI direct interface
DirectShow
all other x64 source filters work, should be around 6-7 source filters they work all
Can you please provide a proper crash dump?
I think the crash I was getting was using a debugger, I'll try it now.
videoh
10th May 2015, 17:02
Waiting for your crash dump, thank you.
Groucho2004
10th May 2015, 17:03
MeGUI direct interface
I wasn't aware that there is a 64 Bit megui version. If I recall correctly, megui uses an ancient wrapper from dimzon, not sure if that's a reliable way to interface with AVS+ x64.
stax76
10th May 2015, 17:04
I'm not able to crash it but the debugger breaks at AVIFileGetStream with message:
exception raised at 0x00007FFE9601A783 (DGDecodeNV.dll) in StaxRip.exe: 0xC0000005: access violation at writing at position 0x00000000EFBEC59F.
Can you mail me a debug build with debug symbols?
stax76
10th May 2015, 17:06
I wasn't aware that there is a 64 Bit megui version. If I recall correctly, megui uses an ancient wrapper from dimzon, not sure if that's a reliable way to interface with AVS+ x64.
I extracted the code and made a sample application and uploaded the VisualStudio solution yesterday, works pretty fine again with all other 6-7 x64 source plugins.
videoh
10th May 2015, 17:29
I extracted the code and made a sample application and uploaded the VisualStudio solution yesterday, works pretty fine again with all other 6-7 x64 source plugins. Can you please give me the executable as I am not set up for managed app development? And please explain how to run it. That should allow me to reproduce your issue easily.
I'll send the debug build with symbols if I cannot reproduce your issue using your little app.
stax76
10th May 2015, 17:53
Here is the VS solution with build:
http://www.mediafire.com/download/e1q77g9q12y068p/WindowsApplication2.7z
It shows a open file dialog where you open a RGB avs, use ConvertToRGB()
videoh
10th May 2015, 18:17
Perfect, thanks. Investigating...
videoh
10th May 2015, 18:36
OK, I was wrong about where the bug was. :eek: Thanks for your patience in pushing me.
I replaced my hand-rolled aligned_malloc() with _aligned_malloc() and things seem to be working fine now. :D
Just guessing, I think the reason things worked with VirtualDub is that it has a different overall malloc usage than your applications.
Go to the normal place you get DGDecNV binaries and get dgdecnv2049staxrip.zip. Replace your 64-bit dgdecodenv.dll and report your results. When you confirm it is working, I'll make a release.
stax76
10th May 2015, 19:38
It works fantastic, sorry about losing temper.
videoh
10th May 2015, 19:42
Sweet, thanks for your test results. I'm going to slip-stream 2049 right now, so you can advise your users to just re-download 2049 to get the fixed 64-bit binary. Give me 20 minutes.
You're right that I'm clueless about .NET, I don't deny it. I'm just happy that with your little test app, we could find a way for me to reproduce the issue. Thanks for putting that together for us. Onward and upward.
Zathor
10th May 2015, 23:04
I wasn't aware that there is a 64 Bit megui version. If I recall correctly, megui uses an ancient wrapper from dimzon, not sure if that's a reliable way to interface with AVS+ x64.
MeGUI x64 was available ~2 years ago. Since then I have not compiled it anymore as there was no proper 64 bit support, but it should still work.
And yes, it is still using dimzons wrapper. Source can be found here: https://sourceforge.net/p/megui/code/HEAD/tree/AvisynthWrapper/trunk/
Any advises how to improve? I just noticed that the avisynth header is quiet old.
Wilbert
11th May 2015, 18:46
Could you guys tell me what the wrapper does, and how/when you use it?
Zathor
25th May 2015, 18:40
Could you guys tell me what the wrapper does, and how/when you use it?
The wrapper is used in order to process avs files (or even strings in memory only) from managed code (e.g. C#). It has been written by MobileHackerz/dimzon years ago. We only use it from MeGUI (C#) perspective - I have no deeper insight in it.
It seems that the header file is ancient:
AVISYNTH_INTERFACE_VERSION = 2
Zathor
25th May 2015, 18:41
Could you guys tell me what the wrapper does, and how/when you use it?
The wrapper is used in order to process avs files (or even strings in memory only) from managed code (e.g. C#). It has been written by MobileHackerz/dimzon years ago. We only use it from MeGUI (C#) perspective - I have no deeper insight in it.
It seems that the header file is ancient:
AVISYNTH_INTERFACE_VERSION = 2
EDIT: This may explain better for which purposes it is used:
https://sourceforge.net/p/megui/code/HEAD/tree/AvisynthWrapper/trunk/AvisynthWrapper.cpp
Wilbert
25th May 2015, 22:15
Just ask Dimzon to update the header. It doesn't look too difficult to me.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.