This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Divya Marwaha

Greenhorn
+ Follow
since Feb 09, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Divya Marwaha

Thanks all for your valuable and prompt inputs.
strcpy was done from larger size buffer (1024) to 512 size user_cred variable...
Even after making the change the reason I wasn't seeing the crash was because
all the related binaries were not copied on the testing box properly....my bad
Anyhow,Thanks again.
-Divya

10 years ago
Another thing is , when I started running the java GUI app, free disk space was about 27% and later at the time of crash I saw free space of only about 8% (using df -k on solaris sparc box). Also, If one uses terminal based UI (TTYUI using C n C ++ code) then no sort of error in seen. Only when swing based UI is used with native code, jvm dumps..why is it so?? Can it be something to do with jvm heap size or similar issue? If the problem is in native code alone then should it not get reported in some form with other UIs as well which interact with native Code? I am just wondering...expert thoughts will be enlightening for me...
10 years ago
Stack trace for jvm dump mostly points to strcpy (and sometimes strstr, strcat)

  • C [libc.so.1+0x31fd0] strcpy+0x70
    C [libjniapi.so+0x2c60] vts_user_cred+0x94
    C [libjniapi.so+0x2720]
    C [libjniapi.so+0x1d64] vts_connect+0x118
    C [libjniapi.so+0x19e4] __1cQvts_authenticate6F_i_+0x30
    C [libjniapi.so+0x1ad4] Java_com_sun_deg_sunvts_agent_JNILink_vtsCommand+0xc
    j com.sun.deg.sunvts.agent.JNILink.vtsCommand(Ljava/lang/String;)Ljava/lang/String;+15


  • I am including important fn def.


    Ernest Friedman-Hill wrote:Can we see vts_connect? If we saw the call to strstr, then we could figure out where its arguments came from, and that would let us trace where they might possibly go wrong.

    10 years ago
    I made some string related changes in C files (native layer for string manipulation operations)
    The error is still appearing after 24 + hours of running the application. and stack is pointing to same strcpy location.

    Code flow is :
    Swing UI
    |
    java code
    |
    JNI C file (jniapi.cc)
    |
    native layer

    The Swing UI sends command to native layer and native layer returns a response which is displayed by UI.

    code from jniapi.cc is also below which makes calls to native functions.
    ################

    ################

    What sort of JNI optimization can be introduced?

    Thanks,
    Divya



    Ernest Friedman-Hill wrote:Indeed. 999,999 times out of a million, your code might work fine -- but it still may not be coded correctly to deal with thread ownership of references or with the possible data movement that can occur due to garbage collection. That's why I said JNI can be tricky.

    10 years ago
    But once the tests are started from the swing GUI, the progress of tests is shown properly. After 24+ hours run, at some random time the SEGV crash is reported. While tests are running no changes can be made from the GUI.

    Rob Prime wrote:

    Divya Marwaha wrote:Stack: [0xa2980000,0xa2a00000), sp=0xa29feb58, free space=506k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C [libc.so.1+0x68924] strstr+0x20
    C [libjniapi.so+0x1d80] vts_connect+0x134
    C [libjniapi.so+0x19e4] __1cQvts_authenticate6F_i_+0x30
    C [libjniapi.so+0x1ad4] Java_com_deg_agent_JNILink_vtsCommand+0xc
    j com.deg.agent.JNILink.vtsCommand(Ljava/lang/String;)Ljava/lang/String;+0
    j com.deg.agent.JNILink.vtsCommand(Ljava/lang/String;)Ljava/lang/String;+0
    j com.deg.agent.JNILink.executeVTSKCommand(Ljava/lang/String;)Ljava/lang/String;+7

    This is what I see in stack trace. It doesn't appear to be JVM issue.
    Looks like the problem is happening in native function call vts_connect(), Is that so???


    It appears so. That's indirectly called by class com.deg.agent.JNILink, method String vtsCommand(String). Maybe you're passing a null string and it doesn't check for it.

    10 years ago
    Below is what I see in stack trace. It doesn't appear to be JVM issue.
    Looks like the problem is happening in native function call
    vts_connect() and vts_user_cred(), Is that so???


    Stack: [0xa2980000,0xa2a00000), sp=0xa29feb58, free space=506k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C [libc.so.1+0x68924] strstr+0x20
    C [libjniapi.so+0x1d80] vts_connect+0x134
    C [libjniapi.so+0x19e4] __1cQvts_authenticate6F_i_+0x30
    C [libjniapi.so+0x1ad4] Java_com_deg_agent_JNILink_vtsCommand+0xc
    j com.deg.agent.JNILink.vtsCommand(Ljava/lang/String;)Ljava/lang/String;+0
    j com.deg.agent.JNILink.vtsCommand(Ljava/lang/String;)Ljava/lang/String;+0
    j com.deg.agent.JNILink.executeVTSKCommand(Ljava/lang/String;)Ljava/lang/String;+7


    Stack: [0xac200000,0xac280000], sp=0xac27e698, free space=1f9ff231fd0k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C [libc.so.1+0x31fd0] strcpy+0x70
    C [libjniapi.so+0x2c60] vts_user_cred+0x94
    C [libjniapi.so+0x2720]
    C [libjniapi.so+0x1d64] vts_connect+0x118
    C [libjniapi.so+0x19e4] __1cQvts_authenticate6F_i_+0x30
    C [libjniapi.so+0x1ad4] Java_com_deg_agent_JNILink_vtsCommand+0xc
    j com.deg.agent.JNILink.vtsCommand(Ljava/lang/String;)Ljava/lang/String;+15
    j com.deg.agent.JNILink.vtsCommand(Ljava/lang/String;)Ljava/lang/String;+0






    Ernest Friedman-Hill wrote:Looks like some pretty classic C programming issues. Segvs like these

    # C [libc.so.1+0x31fd0] strcpy+0x70

    or

    # C [libc.so.1+0x68924] strstr+0x20


    are very likely just due to passing dangling pointers around in the native code.

    How much do you know about JNI programming? It can be pretty tricky dealing with thread-related memory ownership issues, which I suspect are quite thick in the kind of program you're describing. Maybe you could give us an idea of the scope of your native code, and maybe show us a representative sample.

    10 years ago
    Native code base is pretty huge and complex. To begin with, I will check for dangling pointers. Thanks.
    10 years ago
    Yes I do see the log.
    The trace shows the calls all the way to my JNI code and then points to libc.so.1

    But what exactly should I be looking for ? Could it be an issue in my code or is it JVM code issue?
    10 years ago
    Hi,

    I am working on java swing application(GUI) using JNI code to communicate with native C code. The Swing application launches properly and works fine.
    The GUI is used to start some customized system level tests(io,memory,cpu) and show their progress. The tests have to be left running at-least overnight to get the
    results. However, if I check the next morning, GUI crashes and throws following message.

    Any pointers on source of the issue will be greatly appreciated.

    Java version: java 1.5 / java 1.6
    OS: Solaris 10.

    Thanks,
    Divya
    PS: Also posted on stackoverflow for more insight. http://stackoverflow.com/questions/3008378/swing-gui-using-jni-crashes

    =============MESSAGES==================
    # uname -a
    SunOS Generic_127127-11 sun4v sparc SUNW,
    #
    # #
    # An unexpected error has been detected by HotSpot Virtual Machine:
    #
    # SIGSEGV (0xb) at pc=0xff268924, pid=9473, tid=272
    #
    # Java VM: Java HotSpot(TM) Server VM (1.5.0_14-b03 mixed mode)
    # Problematic frame:
    # C [libc.so.1+0x68924] strstr+0x20
    #
    # An error report file with more information is saved as hs_err_pid9473.log
    #
    # If you would like to submit a bug report, please visit:
    # http://java.sun.com/webapps/bugreport/crash.jsp
    #

    =============================

    Another machine:

    # A fatal error has been detected by the Java Runtime Environment:
    #
    # SIGSEGV (0xb) at pc=0xff231fd0, pid=1406, tid=180
    #
    # JRE version: 6.0_18-b07
    # Java VM: Java HotSpot(TM) Server VM (16.0-b13 mixed mode solaris-sparc )
    # Problematic frame:
    # C [libc.so.1+0x31fd0] strcpy+0x70
    #
    # An error report file with more information is saved as:
    # /usr/sunvts/bin/hs_err_pid1406.log
    #
    # If you would like to submit a bug report, please visit:
    # http://java.sun.com/webapps/bugreport/crash.jsp
    # The crash happened outside the Java Virtual Machine in native code.
    # See problematic frame for where to report the bug.
    #
    10 years ago
    Hi Mark,

    Thanks for your prompt and detailed reply. I will use profiling tool to get more information. If you have any suggestion on the best profiling tool to use, it will be helpful.

    The page in question contains a table displaying some tests and their status.The page also contains some buttons and drop-down menus. The columns of the table displaying the test results need to be updated every 20 seconds or so for effective monitoring of tests. The page size is about 80KB. There is some amount of Java Script(JS) embedded in the page (about 100-150 lines) as well.

    Caching feature was added to speed up table data retrieval.

    Some things I wanted to ask.
    1. In web.xml, currently client side-state save is specified as it is an external applicaiton. I read that client-side state saving uses higher bandwidth. Can that be causing slowness. Are there any good rules of thumb that specify when to store the state on the client or the server?

    2. Will the performance improve if http is used for some pages, instead of https? Current framework uses https for all JSP pages.



    Thanks again in advance!
    Divya
    12 years ago
    JSF
    I am using JSF components in web application. The application response is very slow (about 10s) after user makes any selections. i.e. time between page submission and page re-rendering. How can to improve the response time/performance of web app? The backend processing code takes about 2s and remaining time is taken up by GUI code.
    [ February 09, 2008: Message edited by: Bear Bibeault ]
    12 years ago
    JSF