VBScript Regular Expression Bug?

M

MichaelPyles

Using IIS 5.1, XP, dev studio 2003, ASP
I've discovered an insidious bug with the VBScript Regular Expression
object. I set the pattern to consist of the set of invalid filename
characters plus comma. I set global property to true then do a replace on a
SID. The Replace does nothing. However, if I attach the C++ (dev studio
2003) debugger to the IIS host process (dllhost.exe), every time I call
RegExp.Replace, the stack for one of the process's threads gets scrambled.
It ends up with the value 0x00000001 at the top of the stack! If your
debugger is set to stop on access violations, it always catches one (invalid
read trying to delete). The problem is insidious because, without the
debugger running, you would never know this is happening. ASP returns no
error. Potentially this could wreak havoc on your web application and cause
bizarre failures later on. Has anyone else run into this one? It seems to
happen only with the Replace method.
 
M

MichaelPyles

Here's the asp code. The value for Filename would be a SID (so there should
be nothing to replace).

dim regEx
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = "[,/\:*?""<>|]"
regEx.Global = true
Filename = regEx.Replace(Filename, "")
 
A

Aaron [SQL Server MVP]

Here's the asp code. The value for Filename would be a SID (so there
should
be nothing to replace).

If these are retrieved in any way similar to a GUID() then you might see
http://www.aspfaq.com/2358 ... this returns some extra bogus characters that
can cause problems as well.

In any case, I would guess that the problem lies in the method used to
retrieve the SID (or in the SID data itself), as opposed to a problem in
RegEx.

A
 
M

MichaelPyles

Well... all I can say is that with the code posted as part of my ASP page, I
get the trap in the C++ debugger when attached to dllhost.exe. Without it in
there, everything works ok. I swapped out the use of regExp.Replace with
separate Replace instructions and all is well.
 
M

MichaelPyles

I just verified the SID is OK from the C++ debugger. It gets returned from
one of our COM interface functions. It looks OK. In fact we use in other
places in our ASP app. We also use the regular expression object in many
places in our ASP app. However, in only this only place did we use the
Replace method. Otherwise, it seems to be working ok. (and you wouldn't
know it was doing anything out-of-line unless you had the C++ debugger
attached to dllhost.exe... and even then, perhaps you may not get the same
type of exception, if any, that I get... it's probably random... you would
need to break into the debugger after executing the Replace method and
examine the stack for each thread).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top