Bug #47474 mysqld hits Dbug_violation_helper assert when compiled with Sun Studio compiler
Submitted: 21 Sep 2009 9:19 Modified: 18 Dec 2009 23:47
Reporter: Olav Sandstå Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1.39-debug OS:Solaris
Assigned to: Alexander Nozdrin CPU Architecture:Any
Tags: Sun Studio

[21 Sep 2009 9:19] Olav Sandstå
Description:
When compiling MySQL with Sun Studio compiler and with --with-debug the following assert is hit during startup:

Assertion failed: !_entered, file ../include/my_dbug.h, line 29

The call stack from the core file contains the following:

current thread: t@4
  [1] __lwp_kill(0x4, 0x6, 0xffffffff9d5c4f00, 0xfffffd7fff133abe, 0x0, 0x6), at 0xfffffd7fff13318a 
  [2] _thr_kill(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7fff12e1b3 
  [3] raise(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7fff0dcd79 
  [4] abort(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7fff0bc950 
  [5] __assert(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7fff0bcbde 
=>[6] Dbug_violation_helper::~Dbug_violation_helper(this = 0xfffffd7ffec2cf37), line 29 in "my_dbug.h"
  [7] one_thread_per_connection_end(thd = 0x11fee00, put_in_cache = false), line 1940 in "mysqld.cc"
  [8] handle_one_connection(arg = 0x11fee00), line 1134 in "sql_connect.cc"
  [9] _thr_setup(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7fff12fd7b 
  [10] _lwp_start(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7fff12ffb0 

How to repeat:
Compile MySQL using Sun Studio and with --with-debug and start the MTR test suite. It should crash on the first test run.

Note that this bug only affects builds compiled with --with-debug.
[21 Sep 2009 9:27] Olav Sandstå
This crash happens in the function:

  bool one_thread_per_connection_end(THD *thd, bool put_in_cache)

in mysqld.cc. This function creates the Dbug_violation_helper object and then calles pthread_exit() when the Dbug_violation_helper object is still "active". Even if pthread_exit() is normally not expected to return the destructor for the Dbug_violation_helper object is still run and makes the process hit the assert.

Seems like we have to "disable" the Dbug_violation_helper object before calling phtread_exit().
[23 Sep 2009 13:10] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/84356

3125 Alexander Nozdrin	2009-09-23
      A patch for Bug#47474 (mysqld hits Dbug_violation_helper assert
      when compiled with Sun Studio compiler).
      
      The thing is that Sun Studio compiler calls destructor of stack
      objects when pthread_exit() is called. That triggered an assertion
      in DBUG_ENTER()/DBUG_RETURN() validation logic (if DBUG_ENTER() is
      used in the beginning of function, all returns should be replaced
      by DBUG_RETURN/DBUG_VOID_RETURN macros).
      
      A fix is to explicitly use DBUG_LEAVE macro.
[23 Sep 2009 13:15] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/84359

3613 Alexander Nozdrin	2009-09-23 [merge]
      Merge patch for Bug#47474 from mysql-5.1-bugteam.
[23 Sep 2009 13:26] Alexander Nozdrin
Pushed into mysql-5.1-bugteam.
Merged into mysql-pe.
[6 Oct 2009 9:00] Bugs System
Pushed into 5.1.40 (revid:joro@sun.com-20091006073316-lea2cpijh9r6on7c) (version source revid:alik@sun.com-20090923131023-fiy0zxeaa8ojmlfq) (merge vers: 5.1.40) (pib:11)
[6 Oct 2009 20:47] Alexander Nozdrin
Bug#47792 was marked as a duplicate of this one.
[14 Oct 2009 15:29] Paul Dubois
Noted in 5.1.40 changelog.

Debug builds could not be compiled with the Sun Studio compiler.

Setting report to NDI pending push into 5.5.x+.
[22 Oct 2009 6:36] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091022063126-l0qzirh9xyhp0bpc) (version source revid:alik@sun.com-20091019135554-s1pvptt6i750lfhv) (merge vers: 6.0.14-alpha) (pib:13)
[22 Oct 2009 7:08] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091022060553-znkmxm0g0gm6ckvw) (version source revid:alik@sun.com-20091013094238-g67x6tgdm9a7uik0) (merge vers: 5.5.0-beta) (pib:13)
[22 Oct 2009 19:55] Paul Dubois
Noted in 5.5.0, 6.0.14 changelogs.
[18 Dec 2009 10:35] Bugs System
Pushed into 5.1.41-ndb-7.1.0 (revid:jonas@mysql.com-20091218102229-64tk47xonu3dv6r6) (version source revid:jonas@mysql.com-20091218095730-26gwjidfsdw45dto) (merge vers: 5.1.41-ndb-7.1.0) (pib:15)
[18 Dec 2009 10:51] Bugs System
Pushed into 5.1.41-ndb-6.2.19 (revid:jonas@mysql.com-20091218100224-vtzr0fahhsuhjsmt) (version source revid:jonas@mysql.com-20091217101452-qwzyaig50w74xmye) (merge vers: 5.1.41-ndb-6.2.19) (pib:15)
[18 Dec 2009 11:06] Bugs System
Pushed into 5.1.41-ndb-6.3.31 (revid:jonas@mysql.com-20091218100616-75d9tek96o6ob6k0) (version source revid:jonas@mysql.com-20091217154335-290no45qdins5bwo) (merge vers: 5.1.41-ndb-6.3.31) (pib:15)
[18 Dec 2009 11:20] Bugs System
Pushed into 5.1.41-ndb-7.0.11 (revid:jonas@mysql.com-20091218101303-ga32mrnr15jsa606) (version source revid:jonas@mysql.com-20091218064304-ezreonykd9f4kelk) (merge vers: 5.1.41-ndb-7.0.11) (pib:15)