QuickFIX/J

java.lang.StackOverflowError when disconnecting file system

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Default Default
  • Resolution: Fixed
  • Affects Version/s: 1.3.1, 1.4.0
  • Fix Version/s: 1.5.1
  • Component/s: Engine
  • Labels:
    None
  • Environment:
    Mandriva Linux 2008 EDT, kernel 2.6.24.7

Description

The following error occurs when disconnecting the file system where log files are written on:
{quote}
[java] java.lang.StackOverflowError
     [java] at java.io.FileOutputStream.writeBytes(Native Method)
     [java] at java.io.FileOutputStream.write(FileOutputStream.java:247)
     [java] at quickfix.FileLog.writeTimeStamp(FileLog.java:116)
     [java] at quickfix.FileLog.writeMessage(FileLog.java:97)
     [java] at quickfix.FileLog.onEvent(FileLog.java:111)
     [java] at quickfix.LogUtil.logThrowable(LogUtil.java:47)
     [java] at quickfix.LogUtil.logThrowable(LogUtil.java:60)
     [java] at quickfix.FileLog.writeMessage(FileLog.java:106)
     [java] at quickfix.FileLog.onEvent(FileLog.java:111)
     [java] at quickfix.LogUtil.logThrowable(LogUtil.java:47)
     [java] at quickfix.LogUtil.logThrowable(LogUtil.java:60)
     [java] at quickfix.FileLog.writeMessage(FileLog.java:106)
     [java] at quickfix.FileLog.onEvent(FileLog.java:111)
{quote}

Repro steps:
 * Start quickfixj engine using a directory on a removable drive (for instance usb key) as log dir
 * Disconnect removable drive while quickfixj engine is running

Activity

Hide
Sylvestre COZIC added a comment - 22/Jul/09 6:26 PM

I suggest the following patch :

  • In quickfix.FileLog class, writeMessage(FileOutputStream stream, String message, boolean forceTimestamp) method:

- LogUtil.logThrowable(sessionID, "error writing message to log", e);*

+ e.printStackTrace();*

This should prevent StackOverflow error when an exception is raised while logging an exception.

I would also suggest:

  • In quickfix.Session class isStateRefreshNeeded(String msgType) method :

    - return refreshMessageStoreAtLogon && !state.isInitiator() && msgType.equals(MsgType.LOGON);

    + return refreshMessageStoreAtLogon && msgType.equals(MsgType.LOGON);

This will make sure MessageStore#refresh() is called on logon, so that in case of filesystem failure, file storing sequence numbers is reopen when trying to reconnect. By the way, I did not understood clearly why this method returns false when ConnectionType property is set to Initiator

Show
Sylvestre COZIC added a comment - 22/Jul/09 6:26 PM I suggest the following patch :
  • In quickfix.FileLog class, writeMessage(FileOutputStream stream, String message, boolean forceTimestamp) method:
- LogUtil.logThrowable(sessionID, "error writing message to log", e);*
+ e.printStackTrace();*
This should prevent StackOverflow error when an exception is raised while logging an exception. I would also suggest:
  • In quickfix.Session class isStateRefreshNeeded(String msgType) method :
    - return refreshMessageStoreAtLogon && !state.isInitiator() && msgType.equals(MsgType.LOGON);
    + return refreshMessageStoreAtLogon && msgType.equals(MsgType.LOGON);
This will make sure MessageStore#refresh() is called on logon, so that in case of filesystem failure, file storing sequence numbers is reopen when trying to reconnect. By the way, I did not understood clearly why this method returns false when ConnectionType property is set to Initiator
Hide
Sylvestre COZIC added a comment - 28/Jan/10 11:44 AM

Hello,

Do you need further information to fix this issue?

Best regards,

Show
Sylvestre COZIC added a comment - 28/Jan/10 11:44 AM Hello, Do you need further information to fix this issue? Best regards,
Hide
Eric Deshayes added a comment - 26/Apr/11 7:18 PM

committed on integration branch rev 1018

Show
Eric Deshayes added a comment - 26/Apr/11 7:18 PM committed on integration branch rev 1018
Hide
Steve Bate added a comment - 02/May/11 8:27 PM

It seems to me that the safest and simplest approach to avoiding the StackOverflow is to simply write the exception message, stack trace and session ID to the standard error stream. The modified code delegates the logging to the SLFJ logger but that logger may also be writing to the same removed file system. This will cause another exception which will be caught in the MINA-related code (when logging incoming messages). It's not clear to me if this will be another source of a StackOverflow or not or result in some other undesired behavior.

Show
Steve Bate added a comment - 02/May/11 8:27 PM It seems to me that the safest and simplest approach to avoiding the StackOverflow is to simply write the exception message, stack trace and session ID to the standard error stream. The modified code delegates the logging to the SLFJ logger but that logger may also be writing to the same removed file system. This will cause another exception which will be caught in the MINA-related code (when logging incoming messages). It's not clear to me if this will be another source of a StackOverflow or not or result in some other undesired behavior.
Hide
Eric Deshayes added a comment - 03/May/11 3:24 PM

As discussed with Steve, it is safest to log the error to the standard error stream.
Committed on integration branch rev#1028.

Show
Eric Deshayes added a comment - 03/May/11 3:24 PM As discussed with Steve, it is safest to log the error to the standard error stream. Committed on integration branch rev#1028.

People

Vote (1)
Watch (3)

Dates

  • Created:
    20/Jul/09 12:12 PM
    Updated:
    20/May/11 2:16 PM
    Resolved:
    20/May/11 2:16 PM