https://issues.apache.org/bugzilla/show_bug.cgi?id=52627

             Bug #: 52627
           Summary: Segmentation in org.apache.tomcat.jni.File.infoGet()
                    native method
           Product: Tomcat Native
           Version: 1.1.22
          Platform: Macintosh
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Library
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: ivmay...@gmail.com
    Classification: Unclassified


Created attachment 28291
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28291
Source code for the repro case

There is a potential segfault in the tomcat native wrappers around
apr_file_info_get() (which themselves probably wrap the fstat() and stat()
syscalls).

I've attached a simple java file that reproduces this 100% of the time on my OS
X 10.7 system with tomcat-native-1.1.22. I'm not sure if infoGet() is actually
used in the tomcat server codebase, I stumbled upon the bug in my own project
that uses the tomcat native library's JNI wrappers around Apache Portable
Runtime.

Repro instructions:

1) Download and build tomcat-native (I think I got the source from
https://github.com/apache/tomcat-native and followed the instructions). You may
need to install libapr (apache portable runtime) through apt-get or port or
whatever package manager you use.

2) Download the TomcatNativeCrash.java attachment
3) Copy tomcat-native-*-dev.jar to the same directory as the attachment.
4) Copy the libtcnative library files for your architecture to the same
directory as the attachment (they get built into
tomcat-native/jni/native/.libs)
3) Build the repro case with:

javac -classpath ./tomcat-native*.jar:. TomcatNativeCrash.java

4) Run the repro case with:

java -Djava.library.path=. -classpath ./tomcat-native*.jar:.
./TomcatNativeCrash.java

The repro just opens a file descriptor to the file named by the first argument
(its own source in the example), creates a FileInfo structure, and tries to
fstat it via org.apache.tomcat.jni.File.infoGet() 100,000 times. This segfaults
for me every single time.

I've coded up a fix and submitted it as a pull request on github:
https://github.com/apache/tomcat-native/pull/1

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to