Вопрос

I am working on this problem for two days and this is driving me mad as I am still quite new to C++. This violation access problem may be quite easy to you and may be answered thousands of times. But my lack of C++ knowledge make me even unable to identify the same problem ever answered.

OK here is my problem:

1. The major code is in a DLL. I am using Visual Studio 2008

2. This DLL called 3 external libraries: boost, tinyXML and SRILM (a NLP toolkit).

3. The error says: Unhandled exception at 0x5f4f068f (TextNormalizerAPI.dll) in tester.exe: 0xC0000005: Access violation reading location 0x00000000. , occurred only in Debug mode. And the error line was caused by an initialization of a boost::regex object (patUsername = regex("^\\W*@[A-Za-z]");) in my code, but the actual position was deeply inside the boost library, as shown in below figure:

The error occurred in boost lib, not in my code

**in most cases, I am not supposed to change the source code of Boost lib, isn't it? **

4. This error occurred only in Debug version, not in Release version.

5. I replace the whole solution with a old but fault-free version which worked properly in Debug mode. Yet immediately after I generating a Release version of this solution, error occurred in Debug mode!

UPDATE:

6. Thank you guys! I just tried something and found out that even a simple define a regex object in the first line of the entry of DLL will incurred this error! Any ideas?

7. yet initialize a regex object in the first line in the main() of the caller of this dll will not incur this problem.

Hope this description will help you recall something and give me some hint.

I want to ask:

what's the usual strategy to narrow down and spot the problem? thank you!

Это было полезно?

Решение

Looking at your code, you may want to verify that your m_position values are valid ... I'm seeing a escape_type_class_jump label in your code, so the goto or whatever mechanism you're using to jump to that label (I can't tell from the screen-shot) may be bypassing whatever checks are being done to verify that your position increments are still valid.

Другие советы

It looks to me like "this" (i.e., the basic_regex_parser) is NULL, and it's trying to call a method on a NULL object, which obviously doesn't work well. If "this" is indeed NULL (you can tell by looking in the "Locals" tab, then I would go up the call stack to the "basic_regex_implementation" level and see what's going on there -- where is this NULL value coming from? In general, looking at different levels of the call stack, and at the variables' values in those levels, will be helpful.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top