Bug #658 StackOverflowError occured
Submitted: 15 Jun 2003 23:28 Modified: 28 Mar 2014 11:38
Reporter: Jongpil Won Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:3.0.8 OS:Linux (linux)
Assigned to: Alexander Soklakov CPU Architecture:Any

[15 Jun 2003 23:28] Jongpil Won
Description:
status:
   mysqld start
   client start
      Connection.setAutoCommit(false);
   mysqld stop
      SendQuery 
   infinite loop occured..

java exception msg:
java.lang.StackOverflowError
at java.lang.Exception.<init>(Exception.java:41)
at java.io.IOException.<init>(IOException.java:40)
at java.net.SocketException.<init>(SocketException.java:29)
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:113)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1477)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1405)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:879)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:945)
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:917)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1841)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)

at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
at com.mysql.jdbc.Connection.close(Connection.java:1028)
at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)

at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
at com.mysql.jdbc.Connection.close(Connection.java:1028)
at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)

... infinite loop

reason:
when Connection closed by accident and AutoCommit mode off,
Driver want to ROLLBACK, so send 'rollback' to mysqld,
but that commend make another error status (connection failed..),
so, try to send rollback, make error, ... ... ...

please check it.

How to repeat:
every time status meet.

Suggested fix:
When connection failed exception,
DO NOT CALL rollback at ANY MODE (autoCommit or not) ...
[16 Jun 2003 6:45] Mark Matthews
Are you absolutely _sure_ you're using 3.0.8? Your stacktrace doesn't match 3.0.8 either in line numbers or in execution path. The cleanup() method in 3.0.8 doesn't call 'close', it calls 'realClose()'.
[7 Aug 2003 15:21] Mark Matthews
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
[25 Aug 2004 0:52] Steve McGregory
I have Connector/J version 3.0.12 and I get into this same problem all the time.  Please advise

Here is the stack trace

14:36:15:367 PM java.lang.StackOverflowError
14:36:15:375 PM         at java.net.SocketException.<init>(SocketException.java:29)
14:36:15:375 PM         at java.net.SocketOutputStream.socketWrite0(Native Method)
14:36:15:375 PM         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
14:36:15:375 PM         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
14:36:15:375 PM         at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)
14:36:15:375 PM         at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:124)
14:36:15:375 PM         at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1478)
14:36:15:376 PM         at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1405)
14:36:15:376 PM         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:879)
14:36:15:376 PM         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:945)
14:36:15:376 PM         at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:917)
14:36:15:376 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1841)
14:36:15:376 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:376 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:376 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:377 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:377 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:377 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:377 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:377 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:377 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:377 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:377 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:377 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:377 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:378 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:378 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:378 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:378 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:378 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:378 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:378 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:378 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:378 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:378 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:379 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:379 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:379 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:379 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:379 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:379 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:379 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:379 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:379 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:379 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:379 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:380 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:380 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:380 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:380 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:380 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:380 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:380 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:380 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:380 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:381 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:381 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:381 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:381 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:381 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:381 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:381 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:381 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:381 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:381 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:382 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:382 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:382 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:382 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:382 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:382 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:382 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:382 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:382 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:382 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:382 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:383 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:383 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:383 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:383 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:383 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:383 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:383 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:383 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:383 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:383 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:384 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:384 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:384 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:384 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:384 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:384 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:384 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:384 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:384 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:384 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:385 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:385 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:385 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:385 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:385 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:385 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:385 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:385 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
.......

14:36:15:481 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:481 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:481 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:481 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:481 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:482 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:482 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:482 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:482 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:482 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:482 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:482 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:482 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:483 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:483 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:483 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:483 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:483 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:483 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:483 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:483 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:483 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:484 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:484 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:484 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:484 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:484 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:484 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:484 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
14:36:15:484 PM         at com.mysql.jdbc.Connection.close(Connection.java:1028)
14:36:15:484 PM         at com.mysql.jdbc.Connection.cleanup(Connection.java:2050)
14:36:15:485 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1853)
14:36:15:485 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1787)
14:36:15:485 PM         at com.mysql.jdbc.Connection.execSQL(Connection.java:1768)
14:36:15:485 PM         at com.mysql.jdbc.Connection.rollbackNoChecks(Connection.java:1369)
14:36:15:485 PM         at com.mysql.jdbc.Connection.rollback(Connection.java:1356)
[25 Aug 2004 1:09] Mark Matthews
3.0.12 is not current, 3.0.14 is. Does it have the same stack trace? Given the code that is in 3.0.14 (and 3.0.12), I'm not sure how I see the same error can happen (maybe this is a different bug)?
[25 Aug 2004 1:13] Mark Matthews
I just double checked, at least in 3.0.14 this shouldn't happen as cleanup() tells the driver not to issue a rollback().
[25 Aug 2004 1:23] Steve McGregory
3.0.14 seems to have fixed the problem I was seeing.  Will update if that changes.
[28 Mar 2014 11:38] Alexander Soklakov
Fixed in 3.0.14