Menu

#652 OutOfMemoryError in DirectoryMonitor if monitored path contains recursive symlinks

3.0
closed-fixed
None
5
2014-08-22
2014-01-13
No

When monitored path contains recursive symlinks, recursive calls to readDir() consume all memory.

Uncatched exception in thread [DirectoryMonitor]
Error: java.lang.OutOfMemoryError: GC overhead limit exceeded
Error: at java.lang.StringCoding$StringEncoder.encode(Unknown Source)
Error: at java.lang.StringCoding.encode(Unknown Source)
Error: at java.lang.String.getBytes(Unknown Source)
Error: at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
Error: at java.io.UnixFileSystem.getBooleanAttributes(Unknown Source)
Error: at java.io.File.isDirectory(Unknown Source)
Error: at org.omegat.util.DirectoryMonitor.readDir(DirectoryMonitor.java:140)
Error: at org.omegat.util.DirectoryMonitor.readDir(DirectoryMonitor.java:141)
Error: at org.omegat.util.DirectoryMonitor.readDir(DirectoryMonitor.java:141)
...

For example, to reproduce it one can create one-step loop in dictionaries' directory with (in Linux)
ln -s . qq

In my case I've got this issue because some time ago path to dictionaries directory was set in config to root directory ('/'). Enumerating root directory took a lot of time on dev machine, also some toolchains and links in procfs have recursive links.

Quick and dirty fix attached. It fixes OutOfMemoryError , but if one of monitored directories is set to root, CPU and memory consumption still large.

1 Attachments

Discussion

  • Didier Briel

    Didier Briel - 2014-01-13
    • status: open --> accepted
    • assigned_to: Alex Buloichik
    • Group: SVN --> 3.0
     
  • Didier Briel

    Didier Briel - 2014-01-13

    Alex will apply the fix himself, after reviewing and adapting it.

    Didier

     
  • Didier Briel

    Didier Briel - 2014-01-21
    • status: accepted --> open-fixed
     
  • Didier Briel

    Didier Briel - 2014-01-21

    Fixed in SVN (/trunk).

    The patch was slightly rewritten, and moved to FileUtil.

    Didier

     
  • Didier Briel

    Didier Briel - 2014-01-23
    • status: open-fixed --> closed-fixed
     
  • Didier Briel

    Didier Briel - 2014-01-23

    Fixed in the released version 3.0.8 update 2 of OmegaT.

    Didier

     

Log in to post a comment.