0

I wanted to show my students how to use regular expresions. As they are learn programming in C, I thought it would be the best to use regex.h from GnuWin32 (http://gnuwin32.sourceforge.net/packages/regex.htm). As an example I tried to run http://www.peope.net/old/regex.html programm, but it causes an exception on the variable holding the regular expression at runtime . The precise error message is:

Run-Time Check Failure #2 – Stack around the variable 'regex' was corrupted

The courius thing is that the example itself is running properly and the regex functions seems to work properly. The error happens after all the important things are over at the point where main() wants to return.

Has anybody an idea of why this error occurs? Could the 64-Bit System I'm using be part of the problem?

Thanks for any advice!

  • Something somewhere smashed the stack, which is detected at the end of the function giving this runtime error. – Some programmer dude May 21 '13 at 12:42
  • Sure, but it seems that this stack corruption is performed by the regex library, not by sample programm itself. However, I reckon that very clever people are working in the Gnu-Project and that they have tested the functions properly. That is why I thought this problem could be caused by the 64-bit System. But does it? – Kai Benjamin Heinz May 22 '13 at 10:52
  • Well the package is pretty old, from before 64-bit systems became as prevalent, so it's not unlikely that there is some undefined behavior when used on a 64-bit system. By the way, did you compile the regex package from source or used the pre-compiled package? If you used the pre-compiled package it might work with you just recompiling the package yourself. – Some programmer dude May 22 '13 at 13:19
  • Thanks for your advice. I use a fairly simple lib now, called [SLRE](https://code.google.com/p/slre/). It is not the best on the market, but seems to be the best for my purposes. – Kai Benjamin Heinz May 27 '13 at 09:07

0 Answers0