#90 Stackoverflow/loop in getPoolManager

closed
nobody
None
5
2012-05-13
2010-12-16
Anonymous
No

When AbstractPoolBackedDataSource.getPoolManager gets called, and the assertCpds() method fails, an infinite loop is caused. Included part of the stack trace below, it seems to be that toString() gets called in assertCpds() when the is_closed is true, and the toString() method in turn implicitly calls getPoolManager - causing the loop.

- locked <0xc0> (a java.lang.StringBuffer)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.assertCpds(AbstractPoolBackedDataSource.java:447)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getPoolManager(AbstractPoolBackedDataSource.java:459)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getNumThreadsAwaitingCheckoutDefaultUser(AbstractPoolBackedDataSource.java:203)
at sun.reflect.GeneratedMethodAccessor125.invoke(Unknown Source:-1)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source:-1)
at java.lang.reflect.Method.invoke(Unknown Source:-1)
at com.mchange.v2.beans.BeansUtils.extractAccessiblePropertiesToMap(BeansUtils.java:359)
at com.mchange.v2.beans.BeansUtils.appendPropNamesAndValues(BeansUtils.java:324)
at com.mchange.v2.c3p0.ComboPooledDataSource.toString(ComboPooledDataSource.java:539)
at java.lang.String.valueOf(Unknown Source:-1)
at java.lang.StringBuffer.append(Unknown Source:-1)
- locked <0xc1> (a java.lang.StringBuffer)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.assertCpds(AbstractPoolBackedDataSource.java:447)

Discussion

  • Svante v. Erichsen

    I believe that the problem could be solved by adding "numThreadsAwaitingCheckout", "numThreadsAwaitingCheckoutAllUsers", and "numThreadsAwaitingCheckoutDefaultUser" to TO_STRING_IGNORE_PROPS of ComboPooledDataSource.java.

    On the other hand, I have the hunch that a whitelist instead of a blacklist should be used in this toString() method, so that you can be reasonably sure that it is safe to use when building an exception text.

     
  • Svante v. Erichsen

    I have submitted a patch for this (ID 3525772).

     
  • Steve Waldman

    Steve Waldman - 2012-05-13
    • status: open --> closed
     
  • Steve Waldman

    Steve Waldman - 2012-05-13

    Fixed (not as you suggested by hand-coding toString, although that would certainly be reasonable, but by blacklisting methods that were not but ought to have been blacklisted).

    Will show up in the next minor release (hopefully soon), available now via github.

     

Log in to post a comment.