Regex lib bug: wrong alignment on 64 bit platforms

Hello, The regex library contains an alignment bug that leads to bus errors on 64 bit platforms (in particular, Sun and HP). To reproduce, compile regular expression '(?>a+b|a+)bc+' with flags regex_constants::normal. This should raise SIGBUS in perl_matcher<>::push_alt(). As a fix, I suggest forcing alignment of structure saved_state in perl_matcher_common.cpp: struct saved_state { < unsigned int id; < saved_state(unsigned i) : id(i) {} -> union align -> { -> unsigned int id; -> void* dummy; -> align(unsigned i) : id(i) {} -> } id_aligned; -> saved_state(unsigned i) : id_aligned(i) {} }; and further down below: < unwinder = s_unwind_table[m_backup_state->id]; -> unwinder = s_unwind_table[m_backup_state->id_aligned.id]; The other saved_* structures that get pushed onto the stack seem fine for now. Regards, Ralph

The regex library contains an alignment bug that leads to bus errors on 64
bit platforms (in particular, Sun and HP). To reproduce, compile regular expression '(?>a+b|a+)bc+' with flags regex_constants::normal. This should raise SIGBUS in perl_matcher<>::push_alt(). That's a known issue, and was fixed in cvs a while ago, with almost the same fix that you used: struct saved_state { union{ unsigned int id; // these ensure that this struct gets the same alignment as derived structs: void* padding1; std::size_t padding2; std::ptrdiff_t padding3; }; saved_state(unsigned i) : id(i) {} }; John.
participants (2)
-
Benzinger, Ralph
-
John Maddock