 |
| Caled |
Posted: Tue Apr 08, 2008 11:30 pm
[2.22] Improvement: compatibility report |
 |
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sat Apr 26, 2008 7:34 am |
Well here it is. It's my prompt trigger.
| Code: |
| ^(\d+)h, (\d+)m ([xecdbzypifawhl ]*)(\(?\-\)?) |
As soon as I delete that there is no more access violation error. |
|
|
|
 |
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sat Apr 26, 2008 1:14 pm |
Well Zugg I narrowed this down completely now.
Specifically, this is what is causing the access violation in my prompt trigger.
Using this statement:
| Code: |
| #if (%pos( x, $var)) {defense=1} {defense=0} |
That's not the exact expression, but any variation of that in my prompt trigger causes the access violation error and termination of CMUD. If I cut those out, I get no error. As soon as I put one back in, it crashes when running the compatibility report.
Hmm, it also crashes with this statement.
| Code: |
| #if (%match( $var, x)) {defense=1} {defense=0} |
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Sat Apr 26, 2008 2:58 pm |
Does it matter what the trigger pattern is when using those commands? Does it still crash even if the trigger pattern is empty? If it's not the trigger pattern, then that rules out the PCRE.DLL library.
In your example, you have a reference to $var. Is that local variable defined elsewhere in the script? Or is that the only line in the script?
I'm most interested in the first example with %pos, since %pos is a very simple function. The %match command might be trying to parse something as a pattern, but %pos is just looking for string values. |
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Sat Apr 26, 2008 4:29 pm |
I can't seem to find a combination to replicate a crash with those lines. I am rather concerned about this since the address shown in your screen shot is in the range of the preferred space for the PCRE.DLL, and that type of crash would be consistent with the dll causing the exception.
The only thing I can think that would cause such a problem is an invalid pointer being passed into the PCRE. The only pointer the dll uses for normal write operartions is the FVector array which is held as part of the interface object. The only other time it writes to a pointer addressed space is when it has just requested and received a new pointer from the memory manager.
The error looks like a memory overwrite issue corrupting that vector pointer and may be quite hard to track down. I will see if I can add some exception handling in the dll, so that I can pass the exception up to the calling program. This would of course not be available in a future upgrade of the PCRE, but if I can do it then it should help to locate the bug long before an update of the PCRE becomes available.
I can't really see how it could be a bug in either the interface object or the dll itself without causing random crashes everywhere. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sat Apr 26, 2008 11:08 pm |
| Zugg wrote: |
Does it matter what the trigger pattern is when using those commands? Does it still crash even if the trigger pattern is empty? If it's not the trigger pattern, then that rules out the PCRE.DLL library.
In your example, you have a reference to $var. Is that local variable defined elsewhere in the script? Or is that the only line in the script?
I'm most interested in the first example with %pos, since %pos is a very simple function. The %match command might be trying to parse something as a pattern, but %pos is just looking for string values. |
Well you have my package. :-) My prompt trigger is in the Basic class folder. It doesn't matter what the trigger pattern is. It's the %pos and %match. In the script I use the local variable $flags which is defined at the beginning of the script as %3. If I cut all those statements out of the script, I can run the compatibility report 100 times and it works fine. As soon as I put one if %pos blah blah back in it creates the access violation error.
The compatibility report shows a random trigger though when it is running the scan. However, what is causing the error are those statements in the prompt trigger.
In the compatibility report it shows it is compiling this trigger:
| Code: |
<trigger priority="4610" regex="true" id="152">
<pattern>^You bow your head and bid fare-the-well to your senses\.</pattern>
<value>blind=1
deaf=1</value>
</trigger> |
That's not even the trigger that is causing the problem and in a different class folder.
| Quote: |
| Does it matter what the trigger pattern is when using those commands? |
Yes. It is only when it is in my prompt trigger. I created a test trigger with them and got no error. I can't understand why or what the problem is with my prompt trigger. There are no syntax errors and it works fine. It just causes an access violation error when I run the compatibility report. I'm at a loss really as to WHY it is. |
|
|
|
 |
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sun Apr 27, 2008 2:21 am |
Anyone have an idea of why it is only in my prompt trigger this error happens? That trigger has priority 1.
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Apr 28, 2008 5:06 pm |
The problem is that nobody else can reproduce this, so it's going to be hard.
Can you try changing the pattern of your Prompt trigger to something else to see if it matters what the exact pattern is? If you could determine what part of the prompt trigger pattern is causing the problem, that might help track it down. |
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Apr 28, 2008 7:30 pm |
Vijilante: Is there a "standard" compiled PCRE76.DLL somewhere on the net that OldGuy might be able to download and replace the CMUD PCRE76.DLL with to see if this problem is with our changes to it or not?
OldGuy2: If you create a new package with *only* your prompt trigger in it, does it still cause the crash in the Compatibility report? |
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Mon Apr 28, 2008 10:36 pm |
There is a link to the a precompiled 7.0 version of pcre from the authors page http://www.pcre.org
That version should run for testing this particular issue. It is actually rather tough to find a good dll for the current version. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Apr 28, 2008 10:59 pm |
OK, thanks.
So OldGuy2, here is what you should try:
1) Go to http://gnuwin32.sourceforge.net/packages/pcre.htm and click on the "Binaries" link to get the PCRE binary.
2) Unpack the ZIP file to a directory on your computer. In the "bin" folder within this ZIP you will see a file called "PCRE3.DLL".
3) In your CMUD directory, rename the PCRE76.DLL file to PCRE76_orig.DLL. Then copy the PCRE3.DLL from the "bin" directory in step 2 to your CMUD directory
4) Rename the PCRE3.DLL file in your CMUD directory to PCRE76.DLL
Now try running CMUD and doing the compatibility report to see if it works any differently. Post your results. |
|
|
|
 |
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Wed Apr 30, 2008 3:43 am |
Guess what that works!
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Apr 30, 2008 6:26 am |
OK, that's very interesting. So Vijilante: any idea what might be different between the 2 DLLs that might cause this kind of problem on Windows XP?
|
|
|
|
 |
Rorso Wizard
Joined: 14 Oct 2000 Posts: 1368
|
Posted: Wed Apr 30, 2008 11:23 am |
| Zugg wrote: |
| OK, that's very interesting. So Vijilante: any idea what might be different between the 2 DLLs that might cause this kind of problem on Windows XP? |
My guess is an uninitialised variable somewhere. That is a common mistake in C/C++ that can produce code that seem to work "sometimes". Some C/C++ compilers I have encountered initialize pointers to 0 in debug mode, which can make it tough to find such bugs.
Other suspects could be things like returning a pointer to a variable that is only alive inside a non global block and is not static, or overwriting memory somewhere. Overwriting memory in C/C++ is a really messy thing that can make code appear to crash in entirely unrelated spots, but I think latest MSVC++ has code to help prevent that from happening(buffer security check). |
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Wed Apr 30, 2008 11:27 am |
I can't find any reason for it to not fail with the other dll. Both dll's use the same set of compile options in terms of what features are turned on and how the PCRE goes about its work.
According to oldguy2's screen shot the failure point is this
| Code: |
| 6950F13E 8995ECFEFFFF mov [ebp-$00000114],edx |
which is part of this line of source code
| Code: |
static int
match(REGISTER USPTR eptr, REGISTER const uschar *ecode, const uschar *mstart,
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,
int flags, unsigned int rdepth) |
The particular item being put into the stack there is the ecode pointer. As called from this line
| Code: |
| rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0); |
I haven't put tools to CMud yet to see if the destination address is near the normal stack range, but even if it was it doesn't explain the reason one dll is failing and the other isn't. There also is no sensible logic for why no one else can replicate it yet. I am quite at a loss. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Apr 30, 2008 4:28 pm |
OldGuy2: I'd like you to run one more test with the DLL that causes the crash (the one that comes with CMUD).
Can you create a new session and just paste the prompt trigger that causes the crash and nothing else? I need to see if it's really the prompt trigger itself that is causing the problem, or if it's some kind of memory or stack overflow being caused by the large number of other settings in your file.
Also, I *did* find one possible difference. In CMUDPro, I had increased the stack size to $00800000 based upon a recommendation from Vijilante. But I checked the regular version of CMUD and the stack size was still set at only $00100000. So this might cause a difference between CMUD and CMUDPro. If you can still get a 30-day trial for CMUDPro, give it a try and see if it works better than the regular CMUD.
Vijilante: In the Compatibility report, CMUD creates a single RegEx object and then just calls Match for each setting and each regular expression that is used to test for problems. And as you remember, one of those regular expressions *is* quite complex:
| Code: |
^(?>(?:[^\042]|\176\042)*?\042(?!(?:[^\042]|\176\042)*?(?<!\176)\%\{?(?:[tx-]?\d+)\}?
(?:[^\042]|\176\042)*?)'+'(?:[^\042]|\176\042)*?(?<!\176)\042)*(?:[^\042]|\176\042)*?
(\042(?:[^\042]|\176\042)*?(?<!\176)\%\{?(?:[tx-]?\d+)\}?(?:[^\042]|\176\042)*?(?<!\176)\042) |
(broken to multiple lines to prevent post from becoming too wide.)
for matching the %1..%99 within quotes. So maybe PCRE can't handle this complex regex without the larger stack size? |
|
|
|
 |
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Wed Apr 30, 2008 8:12 pm |
Well I changed back to the original dll file. I then created an empty package and pasted my prompt trigger into it and ran the compatibility report. It threw out the access violation error immediately...
So I changed back to the other dll file and ran the compatibility report and no error. |
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Wed Apr 30, 2008 8:21 pm |
Yeah, I remember that particular regex. If it was causing a problem then I would likely see it too, since I ran the compatibilty report on all my good packages, and a fresh import of my old .mud files. My old files are rife with references to %nn and %i in quotes. They are buried deeply throughout all my scripts and if that regex was causing a problem I would have seen it.
After really examining the code for it I am figuring that it is just a bit under 1k per recursive call into the matching engine. That makes a 1Mb stack capable of handling 1100 recursions. That is rather deep. The hard limit was 10,000,000 in the default code for the dll, and I dropped the soft limit in the interface to 5,000,000 just to have it set up. Based on the change list between PCRE 7.0 and 7.6 I don't really see that the stack usage would have changed. I can always take the other dll apart and double check it.
A stack overflow still doesn't cover the statement that the compatibilty report is displaying different items as currently being examined each time the crash occurs. The only way I can imagine that, is if another thread eating just a little bit of the stack and making it over the edge every so often. That particular guess doesn't quite cover no one else replicating it, which is why I am saying it doesn't make sense.
I would definitely reccommend increasing the stack size in any case. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Wed Apr 30, 2008 8:23 pm |
Do you think I could get a copy of the new package with just the prompt trigger that causes a crash?
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Wed Apr 30, 2008 8:37 pm |
Just pm'd you the trigger.
|
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Wed Apr 30, 2008 9:06 pm |
Replicated with exact addresses and it does look like a stack overflow. Some information from examining the CMud proccess while the AV is pending.
| Code: |
Memory - cMUD.exe (10376) at 4/30/2008 5:12:10 PM
Process total address space is 19221 Pages.
0x00031000-0012FFFF (1020 Kb) - <<<Thread 8300 Stack Area>>> Read/Write Private
0x69500000-6952CFFF (180 Kb) - C:\CMUD\PCRE76.dll |
| Code: |
Threads - cMUD.exe (10376) at 4/30/2008 5:13:27 PM
8300 (0x206C) (7FFDF000)
User TEB:7FFDF000
Exception List:0012F1DC
Stack Base:00130000
Stack Limit:00031000 |
I am not quite sure why it seemed to give a random script before, or why no one else was encountering it with something; but it is definitely a stack overflow. It is very possible that just a few bytes of difference in the needs of the 2 dll's could account for why one didn't crash. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Apr 30, 2008 9:40 pm |
Vijilante: Does it also crash in CMUDPro? or just CMUD? If that stack difference is the problem, then 2.23 should help. But it would also be nice if we can figure out how we can trap this to prevent problems in the future. Just increasing the stack space seems like a bit of a kludge and makes me wonder if some other regex would just run into the higher stack limit.
I agree with your reasoning above that it seems pretty amazing that we would be reaching even the lower stack limit. Seems like an awful lot of recursion. |
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Wed Apr 30, 2008 10:20 pm |
I did a curosory examination of the stack data when I captured the information for my post. The few numbers I took the time to interpret came very close to having reached the end of the string. I never quite dug deep enough to determine if it was the %nn regex from above, but all things considered it does seem likely. Since I have a replicateable data set I can try refactoring that regex a few different ways to make it run better.
I haven't checked CMudPro yet, since I have yet to install it for the first time. I will try to give it a go either just before you release 2.23 or right after. Right after is more likely since I have been blocking off the weekend for serious beta testing.
| Zugg wrote: |
| Just increasing the stack space seems like a bit of a kludge... |
About I can on that is to quote a comment in the PCRE source:
| PCRE wrote: |
RECURSION IN THE match() FUNCTION
The match() function is highly recursive, though not every recursive call
increases the recursive depth. Nevertheless, some regular expressions can cause
it to recurse to a great depth. I was writing for Unix, so I just let it call
itself recursively. This uses the stack for saving everything that has to be
saved for a recursive call. On Unix, the stack can be large, and this works
fine.
It turns out that on some non-Unix-like systems there are problems with
programs that use a lot of stack. (This despite the fact that every last chip
has oodles of memory these days, and techniques for extending the stack have
been known for decades.) So.... |
I happen to agree with both of you, there really is no reason to have a stack limit, and there really is very little reason to need that much stack.
When I examined what was stored in the stack at the crash point about 9/10ths of it was binary 0's, if I had massive amounts of spare time I would readjust the whole thing. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Apr 30, 2008 10:27 pm |
| Quote: |
| I have been blocking off the weekend for serious beta testing. |
Oh no...that means you'll report more bugs that I'll have to fix next week!!
But seriously, it's great that you'll be able to do a lot of beta testing this weekend. Just remember to only report the issues that you think are really serious for a public version, and mainly concentrate on new problems that might be side effects of some new bug fixes. I've only got a couple of days next week to tweak 2.23 into 2.24, and if I end up needing to change even more low-level stuff, then even 2.24 might be bad. So I'm not going to change low-level stuff next week unless I absolutely have to. I really want to get a public version that is better than the current 2.18 version released before I go to Albuquerque for a week, and no version is ever going to be "bug free".
So be kind  |
|
|
|
 |
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Wed Apr 30, 2008 10:59 pm |
Vijilante, what do you do IRL? You seem to be far too good at all things related to CMUD 
|
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Wed Apr 30, 2008 11:31 pm |
My primary profession in life is surviving. My secondary profession is self amusement. It has been proven by 6th parties that amused people live longer, and the 7th party sugested CMud. I managed to perfect my primary profession in life withn about 2 seconds of birth, it was quite simple...breathe. So I took the 7th party advice and invested in CMud when I was 4 seconds old. I think it is starting to pay off.
Oh yeah. I am not paid to be funny, it amuses me to cause others to laugh at totaly inopportune moments. Thus continuing my second profession. Of course, I am not actually saying what I get paid for; since that old phrase, "What do you do for a living?", is also answered by, "Breathe."
There you have it. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
|
|
|