inspecting the call stack from a program (was: Re: Extending Functionality: an expedient and questionable approa ch)

Luke Gorrie <>
Fri Mar 21 14:47:21 CET 2003

Ulf Wiger <> writes:

> Interestingly, the (badly written) regexp:first_match() in
> the commented version seems to loop endlessly. Bug or
> feature? The same pattern passed to egrep works fine.

I think it's a bug in the regexp module - matching on certain regexps
fails to terminate.

> Str,"\\([a-z]+[a-z0-9_]*:[a-z]+[a-z0-9_]*+/[0-9]+") of

That marked part is the most likely suspect: * can match nothing, so
*+ can match infinitely many nothings, and the current module will
consider all nothings (i.e. loop forever.)

I've reimplemented the same regexp-matching algorithm learned from
regexp.erl a couple of times and been caught out with this bug. I'm
quite curious to know of a nice fix, since it's a lovely and simple
algorithm. Sofar I haven't found a fix that's pretty enough to adopt

I think I heard rumour of a simple algorithm for transforming regexps
so that they will never hit this case, but I'm not sure.

NB: if you are passing user-supplied regexps to the regexp module,
e.g. from web-forms, this may be a serious problem.


More information about the erlang-questions mailing list