hi,
i'm using boost regex in a multithreaded environment with

os: fedora 7
boost version: 1.33.1
g++: 4.1.2

i've attached a small sample program that crashes often; but not always (once in 4-5 runs)

curiously, the same program runs without any issue on fedora 8, boost 1.34.1. is there any
issue using boost-regex 1.33.1 in multi-threaded environment?


stack trace:
#0  0x00a22402 in __kernel_vsyscall ()
#1  0x00b921c0 in raise () from /lib/i686/nosegneg/libc.so.6
#2  0x00b93ba1 in abort () from /lib/i686/nosegneg/libc.so.6
#3  0x07fa9540 in __gnu_cxx::__verbose_terminate_handler () from /usr/lib/libstdc++.so.6
#4  0x07fa7025 in ?? () from /usr/lib/libstdc++.so.6
#5  0x07fa7062 in std::terminate () from /usr/lib/libstdc++.so.6
#6  0x07fa719a in __cxa_throw () from /usr/lib/libstdc++.so.6
#7  0x00235adb in boost::regex_error::raise () from /usr/lib/libboost_regex.so.2
#8  0x00205f1f in boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fail () from /usr/lib/libboost_regex.so.2
#9  0x0020771f in boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_repeat_range () from /usr/lib/libboost_regex.so.2
#10 0x00218c7e in boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_extended () from /usr/lib/libboost_regex.so.2
#11 0x002087db in boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_open_paren () from /usr/lib/libboost_regex.so.2
#12 0x00218bd6 in boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_extended () from /usr/lib/libboost_regex.so.2
#13 0x002334e4 in boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse () from /usr/lib/libboost_regex.so.2
#14 0x002349c1 in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign () from /usr/lib/libboost_regex.so.2
#15 0x0804babc in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign ()
#16 0x0804bb06 in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign<std::char_traits<char>, std::allocator<char> > ()
#17 0x0804bb42 in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::basic_regex<std::char_traits<char>, std::allocator<char> > ()
#18 0x0804a2b5 in work ()
#19 0x0804a4e7 in thread_func ()
#20 0x00d0f472 in start_thread () from /lib/i686/nosegneg/libpthread.so.0
#21 0x00c3b89e in clone () from /lib/i686/nosegneg/libc.so.6


code:
#include <boost/regex.hpp>
#include <iostream>
#include <string>
#include <pthread.h>

using namespace std;

void work(const std::string& input, const std::string& pattern, const std::string& replace_by,
        const std::string& card, int thread_id)
{
    const boost::regex search_pattern(pattern);
    const boost::regex card_pattern(card);

    std::string out = regex_replace(input, search_pattern, replace_by, boost::match_default);
    std::cout << thread_id << ": " << out << endl;
}

void* thread_func(void* id)
{
    const string input = "0123-4567-8901-2345";
    const string pattern = "1";
    const string replace_by = "one";
    const string card = "(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})";

    int thread_id = (int)id;
    work(input, pattern, replace_by, card, thread_id);

    return 0;
}

const int MAX_THREADS = 32;

int main()
{
    pthread_t threads[MAX_THREADS];
    std::list<pthread_t*> created_thread_ptrs;

    for (int i = 0; i < MAX_THREADS; ++i) {
        if (pthread_create(&(threads[i]), 0, thread_func, (void*)i) == 0) {
            created_thread_ptrs.push_back(&(threads[i]));
        }  
        else {
            cerr << "Error creating thread " << i << endl;
        }
    }

    cerr << "Waiting for threads to terminate\n";
    for (std::list<pthread_t*>::iterator it = created_thread_ptrs.begin();
         it != created_thread_ptrs.end();
         ++it) {
        pthread_join(*(*it), 0);
    }
    return 0;
}