Question

I am building an application and using the x264 library as an encoder. I have built the library for my windows system using MSys/MingW. The library works fine under debug build (note both debug and release builds are using the default VS2010 settings). However, under release an access violation error is thrown at the first call to the x264 library, specifically:

  Unhandled exception at 0x00905a4d in StreamTest.exe:
  0xC0000005: Access violation.

The error is thrown at this line:

x264_param_default_preset((params), "veryfast", "zerolatency");

While I was figuring out how to compile the library I came across a lot of talk about memory alignment in Windows/Visual Studios and how it wasn't particularly compatible with the alignment expected by x264. For example when compiling in MSys I had to enable --enable-memalign-hack. I am wondering if the source of this error might stem from a memory alignment issue which only manifests itself through some setting in my release build. Unfortunately I know almost nothing about the specifics and so have come here.

Can anyone give me some more information regarding the memory alignment issues and any Visual Studio settings which might cause this? Any other tips/pointers to fix this issue are very welcome.

Thanks.

Edit

From answer below:

  1. From the linked SO question I get the impression he added "build with debugger info" to the OpenCV build? Since I'm building the x264 library through MSys with G++ I'm not sure I can do this. I have checked the build settings for my project, and under both release and debug it has debugger info. Not sure if I missed something in that post, please let me know.
  2. I tried the application verifier. It seems that x264 is trying to execute code from non-executable memory as per the App verifier output:

    VERIFIER STOP 0000000000000650: pid 0x1B18: 
    

    Attempt to execute code in non-executable memory (first chance).

    0000000000905A4D : Address being accessed.
    0000000000905A4D : Code performing invalid access.
    000000000021EA90 : Exception record. Use .exr to display it.
    000000000021E5A0 : Context record. Use .cxr to display it.
    

Anything to be gathered from this output?

Thanks again.

Was it helpful?

Solution

Refer to a similar issue here, see if that helps you too.

EDIT

Post that you also want to run your application through AppVerifier

EDIT

In my opinion release "Build with debugger info" amounts to turning on -g switch together with optimization switches and turning off any DEBUG macro. Also if you debugger attached (use Gflags ) to start your process with debugger (grab a copy of windbg and use that to debug).

When the Appverifer stops your process use .cxr command to get context information. That should help pointing out the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top