xt_xn_init_db() locks are initialized twice, leaking resources

Bug #782269 reported by Vladislav Vaintroub
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
Undecided
Vladislav Vaintroub
PBXT
Fix Committed
Undecided
Vladimir Kolesnikov

Bug Description

The loop below is run twice in xt_xn_init_db() . It initialized the same pthread_cond structures each time. It leaks events on Windows (since each pthread_cond contains 3 events that would be created with CreateEvent)

Moreover, it creates problems (i.e debug exceptions) when mysqld is run under application verifier.

Problematic code :

  for (u_int i=0; i<XT_XN_NO_OF_SEGMENTS; i++) {
    seg = &db->db_xn_idx[i];
    XT_XACT_INIT_LOCK(self, &seg->xs_tab_lock);
...
  }

Related branches

Revision history for this message
Vladislav Vaintroub (wlad-montyprogram) wrote :

The code is in xaction_xt.cc (xtPublic void xt_xn_init_db(XTThreadPtr self, XTDatabaseHPtr db)

Revision history for this message
Vladislav Vaintroub (wlad-montyprogram) wrote :
Changed in maria:
assignee: nobody → Vladislav Vaintroub (wlad-montyprogram)
milestone: none → 5.2
Changed in pbxt:
assignee: nobody → Vladimir Kolesnikov (vkolesnikov)
status: New → In Progress
Revision history for this message
Vladimir Kolesnikov (vkolesnikov) wrote :

Hi, Vladislav

thanks for the report.

I was not able to reproduce the problem on MariaDB 5.1/Linux. I also added a simple test which didn't discover any problems. Could this be a MariaDB 5.2-specific problem? I will try MariaDB 5.2/Win7x64 once maria pull completes...

Do you know if the problem happens because the xt_xn_init_db() called twice or because the loop re-inits the same segment twice?

Revision history for this message
Vladislav Vaintroub (wlad-montyprogram) wrote :

I fixed it in maria already.
to reproduce in your non-maria environment, run pbxt test suite having mysqld.exe registered with application verifier. There are couple of interesting things to find with pbxt (of which at least one is still unreported, IIRC index lookup code touched memory behind malloc()ated range)

Revision history for this message
Vladislav Vaintroub (wlad-montyprogram) wrote :

Fixed in 5.2.7

Changed in maria:
status: New → Fix Released
Revision history for this message
Vladimir Kolesnikov (vkolesnikov) wrote :

Did you fix any other PBXT bugs in MariaDB branch? If so then could you please mark them in launchpad, so I could merge them to PBXT trunk.

Revision history for this message
Vladislav Vaintroub (wlad-montyprogram) wrote :

Yes, I fixed couple of PBXT bugs. I marked them in LP

Changed in pbxt:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.