Unexpected behaviour with SuspendThread()

Hi,
I'm building a JVMTI agent in C++ that controls the threads that are running in the JVM. My agent uses bytecode injection and JNI to intercept and suspend a thread ( using SuspendThread(jvmtiEnv* env, jthread thread) ), just before it executes particular bytecode instructions.
When I call jvmti->SuspendThread(NULL) (i.e. to suspend the current thread), I have found that although the current thread does suspend before returning to the Java environment, the lines of C++ code that follow the call to SuspendThread() are executed before the thread is suspended.
The JVMTI documentation says that "If the calling thread is specified, this function will not return until some other thread calls ResumeThread". Am I missing something here?
A simplified version of my agent code looks like this:
#include "SuspendTest.h"
#include <jvmti.h>
#include <string.h>
static jvmtiCapabilities capa;
static jvmtiEnv* jvmti_env;
int counter = 1;
* Called via JNI
JNIEXPORT void JNICALL Java_SuspendTest__1suspendMe
(JNIEnv *, jclass) {
     printf("%d: About to suspend thread\n", counter);     
     jvmti_env->SuspendThread(NULL);
     counter++;
     printf("%d: This should not be reached\n", counter);
     counter++;
     printf("%d: This should not be reached either\n", counter);
* Called when the agent is first loaded...
JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved)
     jint res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_0);
     if (res != JNI_OK || jvmti_env == NULL)
          printf("Error getting environment: %d", res);
     (void)memset(&capa, 0, sizeof(jvmtiCapabilities));
     capa.can_suspend = 1;
     jvmtiError err = jvmti_env->AddCapabilities(&capa);
     if (err != JVMTI_ERROR_NONE)
          printf("Error setting capabilities: %d", err);
     return JNI_OK;
JNIEXPORT void JNICALL
Agent_OnUnload(JavaVM *vm) {}When the Java_SuspendTest__1suspendMe function is called via JNI, I see on the console:
1: About to suspend thread
2: This should not be reached
3: This should not be reached eitherAny suggestions?
I should probably add that this is:
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)
Linux 2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686 GNU/Linux
Edited by: RichardBounds on Jun 19, 2008 2:40 AM

HotSpot doesn't suspend threads in native code as this can cause deadlocks. For this example, I believe it will "self-suspends" if you try to re-enter the VM or the native method exits.

Similar Messages

  • Unexpected behaviour with my navigation buttons

    Hi Guys,
    I've just noticed some strange behaviour for my nav buttons in a project I've recently created. My project uses click boxes to naviage and has a Home Button which jumps from any slide (aside from Question Slides) to the first slide in the project. A next and back click box which are all set to go to the next slide / go to previous slide...
    All works fine and as expected (i.e as soon as I click on the next button it goes to the next slide regardless if audio is still playing of the if the slide has finished playing) until say I get two or three pages in to the project and click the home button. It goes to the first page as expected where I click a go to next slide click box (this one takes a few seconds to appear on this slide) which immediatly goes to the next slide. Here is where my problems start... I click on next and I hear the click sound but it refuses to skip to the next slide - It plays the whole slide (50 seconds worth of audio) before it will go to the next slide...
    For the life of me I cannot see why it would do this.
    The click box is set to infinite attempts.
    Anyone ever had a similar issue???
    Thanks
    JT

    Try fiddling with your Quiz: Settings > Required options to see if they make a difference.

  • Unexpected behaviour with "require password" and screen saver

    In 10.6.x, I checked "Require password after sleep or screen saver begins" and after the invoking the screen saver (via a hot corner) moving the mouse or typing on the keyboard brought up a password dialog.
    In Lion, this is what happens with the same settings:

    That got posted somehow before I finished. Here is what happens:
    The log in screen is displayed.
    I select an account and log in.
    The log in screen is displayed again.
    I am logged in, but have obviously been logged out in the meantime.
    This looks like a bug to me.

  • Unexpected behaviour with FlowN ?

    I've tried FlowN to be more flexible in handling multiple messages. What i did is simple:
    - receive incoming message with multiple childnodes
    - use FlowN to handle each individual childnode
    - assign data to invoke-inputmessage
    - invoke synchronous/asynchronous WS
    What happens:
    - when invoking async WS: runtime error: conflict with BPEL4WS standard (not more than one of the same Invoke allowed)
    - when invoking sync WS: every invocation uses the SAME data. Which means: all the assigns are done, then all the invokes using the same data. The Assigns show the real assigned data!
    Any ideas on this one?

    I've tried FlowN to be more flexible in handling
    multiple messages. What i did is simple:
    - receive incoming message with multiple childnodes
    - use FlowN to handle each individual childnode
    - assign data to invoke-inputmessage
    - invoke synchronous/asynchronous WS
    What happens:
    - when invoking async WS: runtime error: conflict
    with BPEL4WS standard (not more than one of the same
    Invoke allowed)
    - when invoking sync WS: every invocation uses the
    SAME data. Which means: all the assigns are done,
    then all the invokes using the same data. The Assigns
    show the real assigned data!
    Any ideas on this one?If I understood well you assign childnode to variable to be handled by a different process (virtual parallel).
    Check the variable (containing the request) is defined inside the scope of the flowN.
    I hope it helps,
    Good luck

  • Unexpected behaviour with the websites

    Hi,
    We are using internal sites for our enterprise, running on OHS (Oracle HTTP server) and enabled static file cache.
    Thing is, IE seems to be properly caching files and reading them in matter of milli-seconds, but firefox is not.
    Firebug is showing the files are still read from cache, but it's taking lot more than IE.

    That got posted somehow before I finished. Here is what happens:
    The log in screen is displayed.
    I select an account and log in.
    The log in screen is displayed again.
    I am logged in, but have obviously been logged out in the meantime.
    This looks like a bug to me.

  • Unexpected behaviour of Composer with adf-config

    This is a part of my adf-config.xml file:
    <cust:customizableComponentsSecurity xmlns="http://xmlns.oracle.com/adf/faces/customizable/config">
    <cust:enableSecurity value="true"/>
    <cust:actionsCategory>
    <cust:actionCategory name="personalizeActionsCategory" value="#{securityContext.userName eq 'weblogic' ? 'true' : 'false'}"/>
    <cust:actionCategory name="customizeActionsCategory" value="#{securityContext.userName eq 'weblogic' ? 'true' : 'false'}"/>
    </cust:actionsCategory>
    </cust:customizableComponentsSecurity>
    Section upon sets a simple EL to provide security restrictions for user in Composer. When I deploy an application and login at first time everything works fine. But when I log in with user other than 'weblogic' unexpected behaviour appears. After that even 'weblogic' user can not access to personalization and customization options anymore.
    So, the question is - is it a really unexpected behaviour, bug or I missed something? Here is a pretty clear and simple manual that I followed to try to make it work: http://docs.oracle.com/cd/E29597_01/webcenter.1111/e25595/jpsdg_page_editor_security.htm#autoId18
    Edited by: Igor_Petrov on 22.02.2013 5:56
    Edited by: Igor_Petrov on 22.02.2013 5:57

    More information: I tried rebuild again. The Messages folder now has 20418 entries and takes 7.54 Gb of disk space.
    I searched using Spotlight for a unique term which appears in one of the messages and found 8 instances of it. All are the same message, but are separate .emlx files.
    This is getting crazy ...

  • Bug in cursor behaviour with duplicates

    Dear Oracle guys and girls,
    first of all: it sucks that i HAVE to provide business information (company name, address, even phone number) even if i just want to participate in this forum for private reasons. I even have to "unsubscribe" to the newsletters although i never subscribed. Then i have to re-enter my timezone information and email address for the forum, because the settings in my profile are ignored. I think there's some room for improvement in this registration process.
    OK - back to topic. i think i found a bug in the cursor behaviour with duplicate keys. But the behaviour is very consistent, so maybe it's not a bug, but a bad design. (I call it bad because it's totally unexpected and not logical to me).
    I insert some dupes with DB_KEYFIRST; then i create a cursor and iterate over all items in the reverse order (!) with DB_PREV (i also tried DB_PREV|DB_NEXT_DUPE) - no keys are shown.
    Alternatively:
    I insert some dupes with DB_KEYLAST; then i create a cursor and iterate over all items in the reverse order (!) with DB_NEXT (i also tried DB_NEXT|DB_NEXT_DUPE) - no keys are shown.
    cursor->c_get returns the error code -30989 (DB_NOTFOUND).
    Why is it not possible to traverse duplicates in the reverse order? To me it looks like a bug.
    I tested against db 4.5.20.
    Regards
    Chris
    PS: I would love to hear if the bug i reported here: http://groups.google.com/group/comp.databases.berkeley-db/browse_thread/thread/ed471cf6837cb2a6/dd9cda0ad105f401#dd9cda0ad105f401
    will be fixed in the next version.
    Here's a test program:
    int
    main(int argc, char **argv)
    unsigned i;
    int st;
    DB *db;
    DBT key, record;
    DBC cursor, cursor2;
    unlink("test.bdb");
    st=db_create(&db, 0, 0);
    if (st)
    error("db_create", st);
    st=db->set_flags(db, DB_DUP);
    if (st)
    error("db->set_flags", st);
    st=db->open(db, 0, "test.bdb", 0, DB_BTREE, DB_CREATE, 0);
    if (st)
    error("db->open", st);
    memset(&key, 0, sizeof(key));
    memset(&record, 0, sizeof(record));
    st=db->cursor(db, 0, &cursor, 0);
    if (st)
    error("db->cursor", st);
    st=db->cursor(db, 0, &cursor2, 0);
    if (st)
    error("db->cursor", st);
    for (i=0; i<LOOPS; i++) {
    record.data=&i;
    record.size=sizeof(i);
    st=cursor->c_put(cursor, &key, &record, DB_KEYFIRST);
    st=cursor->c_put(cursor, &key, &record, DB_KEYLAST);
    if (st)
    error("cursor->c_put", st);
    while (!(st=cursor2->c_get(cursor, &key, &record, DB_NEXT))) {
    printf("%d\n", *(int *)record.data);
    st=cursor->c_close(cursor);
    if (st)
    error("cursor->c_close", st);
    st=db->close(db, 0);
    if (st)
    error("db->close", st);
    return (0);
    }

    st=cursor->c_put(cursor, &key, &record, DB_KEYFIRST);
    st=cursor->c_put(cursor, &key, &record, DB_KEYLAST);
    if (st)
    error("cursor->c_put", st);
    please delete the first line, it was a cut and paste error. as i said earlier: insert with KEYLAST, query with NEXT.

  • SAP Personas: An unexpected behaviour has been detected and you have been disconnected – please log in again.

    Hallo everyone,
    We are installing Personas and facing several challenges.
    Personas 2 SP02 was installed according to instructions of Note '1848339 - Installation and Upgrade note for Personas' and configured according to the Config Guide v1.3 (rel. May 2014). The referenced notes were also applied as well as the 'How to config - FAQ' blog by Sushant.
    We are able to log on and execute transactions and perform activities successfully (e.g. SE80, SPRO, KB15, etc.).
    When trying to copy a screen the following error appears: 'An unexpected behaviour has been detected and you have been disconnected - please log in again.'
    Thereafter one can simply continue executing transactions without having to log in again.
    Please see the download of the error attached as per blog: SAP Screen Personas Support Tips – client side logging
    The HAR is unfortunately too large to attach. Are there any alternatives?
    Thank you in advance for you assistance!
    Kind regards,
    Daniel
    Message was edited by: Daniel K

    Hi,
    I have never worked on SAP PERSONA but you can try below things
    1)try to use different user or J2ee_admin since it might be same user multiple session case
    2) Try with different browser since plugins can behave unexpectedly
    3)Make entry in host file also
    4) check dev_icm logs
    5) check on ABAP side for dumps in ST22
    Warm Regards,
    Sumit

  • Unexpected behaviour upon pressing the 'Enter' key on dialog screen

    Hi.
    I have two dialog screens that exhibit unexpected behaviour when i pressed the 'Enter' key.
    Screen 1: When I pressed the 'Enter' key, the focus shifted to another input field and the content of the previous input field is cleared. The thing is, I did not have any codes in PAI for 'Enter'. Why is this happening?
    Screen 2: On load, some of the fields on this screen will be disabled. However, when I pressed the 'Enter' key, all the disabled fields become enabled. Again, I did not have any codes that handle the 'Enter' key in PAI. Why is this happening?
    Any help is appreciated.

    Hi Atish.
    Yes, I have used CHAIN... END CHAIN.
    I thought that CHAIN... END CHAIN allows my input fields to be re-activated after an error message is displayed.
    How would CHAIN... END CHAIN cause the unexpected behaviour?
    Thanks.

  • Strange behaviour with Safari.

    Very strange behaviour with Safari this morning.   Pages loading piecemeal or partially.   The content only becomes viewable after the cursor has passed over the area.   Have cleared caches and reported it but I'm wondering if this is a local matter here in the UK.   Anyone suffering similar problems?    Firefox is responding perfectly normally.

    I see a reply has come back via a previous post.   As I am trying to get a response to this one I shan't reply there but I should point out that for me, this is an isolated problem.   I do use open DNS but with no track history of problems there , I can't blame that.
    In the last few minutes normality has returned.

  • Unexpected problem with this printable

    Started by trying to stop the printing of the "Samples" printable that was acquired accidentally.  Tried directions found in the forums to no avail.  Tried through the HP Go manageprint route and never saw the minus sign in the printable header as described.  Trying on the control panel of the printer, I get to the "Select activity" option and select the "Schedule it" icon.  Loading....then error message:  "There was an unexpected problem with this printable.  Please try again later."  I also had problems previously connecting to web services when I tried to scan a document to my email address (which I have done many time previously successfully). Performed wireless network test and all results were good.  Something is screwed up.  Any assistance is appreciated. 

     I suspect the whole setup is "not quite right" and that is not your fault -- it is a multi-step process and if it does go well the first time around, it can seem like the size 14 is a solution to fit the need. I do not have an answer - know that.  The print App is stuck, no doubt about that. I will try and help you straighten out the setup; understand I am not a Printer Expert.  Not.  This may make it worse. You might want to call Cloud Services if you can do so...  SideBar:At the least, the Snapfish bits may be just one more worm in the bucket of troubles - at this point, you might as well Click Reset Snapfish -- frankly, while used to understand what Snapfish is and why it might be on the printer panel, I have never heard of Snapfish Country.  Final note about Snapfish -- if you ever get into some sort of evil loop about logging into (creating) your HP Connected Account and it is offing something about Snapfish account -- saying you have to have the Snapfish account or you can just die and never be able to log into your HP Connected Account:  Give the program what it wants --- it is a bug.  Create the Snapfish account and you will be able to get in.  I did not write the program.  I did not create the bug.  I may have done some stupid things when I wrote code in my life -- this one is not mine.  Smiling. You can "reset" at least the "web services" by simply disabling Web Services on the printer front panel.  This is perhaps a good plan all things considered; you might read first and then decide. The one thing I have noted is that I have never had had any luck resetting, redoing, or entering much of anything from a printer panel.  I lack the patience to type on tiny panels. I do know the Printable / Print App has to be "scheduled", that is, active before it can be cancelled.  So, if it is in some sort of zombie state of half-life, you may want log in to your HP Connected account and make sure the Print App is "active" -- then try to kill it. Also -- see the note below about the Safari browser -- there may be other browsers (Chrome??) that do not handle the HP Connected account management page setup.  There are several parts to the whole "ePrint" business.   The following might be useful to help you make sure you have your setup in place.-----------------------------------------------------------------------------------------Reference:Add Device to Printer See Section:Computer gets Full Feature Software (Printer Software)If you are printing from a mobile device on the same (home) network, then you probably have a home computer in the mix (on that same network).  On that home computer, you would want to have installed the Full Feature Software for the Printer. -----------------------------------------------------------------------------------------ePrint SetupThe ePrint setup on ePrint capable printers involves the setting of the printer's own email address and the switching on of the ePrint service on the printer.  The ePrint email address is the email address to which you send your print jobs from your mobile device(s).  Note that a mobile device can also include your notebook computer.  "If you can send an email, you can use ePrint." -----------------------------------------------------------------------------------------The HP Connected AccountThe HP Connected Account (still called ePrint account in some countrys) is the account you use to manage your ePrint setup.  You can customize your ePrint email address, add / remove your ePrint printer from the HP Connected account, check your ePrint job log, and -- when things are working as intended -- manage your Print Apps (formally Printables). For example,If you have had to Reset Web Services, you may need to log into your HP Connected Account > Settings > and Add your printer. If you have had to Reset Web Services, you must change your Custom ePrint email address. If you gave your ePrint address to someone you no longer "like", you can change the address or remove that person from the "Allowed Senders" list. There are a couple of oddities having to do with the managing of the HP Connected Account.  For all that it is intended to be fully functional under most circumstances, some Browsers do not seem to be able to handle the code in which the WebPage is written.  Safari is notorious for not handling the Print Apps section of the HP Connected setup.   If you have trouble managing the features in  your HP Connected Account, try a different Browser. -----------------------------------------------------------------------------------------Mobile Device / iPad gets an App Once everything else is set up, mobile device(s) can be added to the ePrint setup.  The type of Application used to support the mobile device depends on the device. For example, iPhone and other Apple flavored products typically use those products found in the Apply Store.  Android has its own download, etc. Most devices and printers that can be connected with ePrint or some sort of Cloud or Web services print service are mentioned and / or covered in the Mobile Printing Link in the document. -----------------------------------------------------------------------------------------Troubleshooting and Additional HelpTips, Suggestions, lists, and extra "bits".   When you see a Post that helps you,Inspires you, provides fresh insight,Or teaches you something new,Click the "Thumbs Up" on that Post. Click my Answer Accept as Solution to help others find Answers.

  • IPhoto behaviour with Albums

    can anyone explain or point me in the direction of the reaoning behind iphotos behaviour with Albums and Smart Albums in 2 situations.
    the first, is when using Airpics App and Server, the second when viewing a shared library.
    my set up is my iPhoto main DB is on a headless Mini. I also have a MBP on the same wireless network that view and controls the Mini.
    in situation 1, when my iPad views my Minis library via thr Airpics apps, it says it only views Albums and Smart Albums, not Events but i can see an item that is an event. it consequently is the last full import i do so is the last import considered an album or smart album?
    in 2, when i view my Mini iPhoto DB on my MBP via sharing, lots of Albums and Smart Albums come up from the past that i have deleted. Where is it gettign this info from? is it old stuff from the Minis DB coming through? Or are these current or old stuf from my MBP somehow? when i open the Minis DB on my MBP using Alt-Open and selecting the DB Directly instead of over sharing, these Albums / Smart Albums dont exist. i only see what i expect to see, Currwnt set up..

    thank you again Terence.
    you see ma bit of an iPhoto Guru, Terence and i dont know how else to contact you and i know its niot right to change a thread half way through but do you have any knowledge on the best way to handle this situation:
    i have my iphoto on my headless Mini, controlled by MBP remotely and within the same Wi fi network when home. Iphoto over both is unusably slow. How could i combat this? im told not to use the Mini Library via MBP sleected via ALT when opening as if WiFi drops out it can corrupt. If i use the Sharing from the iPhoto.Mini to MBP, iPhoto.Mini must be open therefore iPhoto.Mini on Sharing on MBP cant be editted, only viewed. The one utility that helps is the iPhoto Manager but all that essentially does is copy from one to another over WiFi so i dont see the difference in that app doing it or me manually doing it, TBH id rather manually do it.
    And i need to store the iPhoto main DB at home as iTunes and my iPad use it while i'm not there, and its now too big to carry around on a 5 year old MBP.
    I like a lot of others seem lost on how to effectively manage and use iPhoto

  • Why does a new desktop creation unexpectedly initiate with a background differing from the originating desktop? How can I control or eliminate this behavior?

    Why does a new desktop creation unexpectedly initiate with a background differing from the originating desktop? How can I control or eliminate this behavior?

    CT, I suspect that I either mistated the question or don't understand how to set the default back ground.  In any case, with the background that I have set in system settings, and this is the background to which my sessions consistantly boot, new desktops come up for the second or up to the third background with this initially set background. Then in the third or fourth desktop creation (I seldom go beyond four), the background for the new desktop, is one that I was using one or two months ago...

  • Strange repaint behaviour with JList & Keyboard actions

    Hi everyone,
    This is my first post to the forum. You guys have been a great help in the past and I hope to contribute more in the future.
    Anyways, I've encountered some strange repainting behaviour with a JDialog that uses a JList and a JButton. The dialog is fairly straight-forward and basically this is how it works (like an open file dialog - yes I'm implementing my own filechooser of sorts):
    * JList lists a number of simple items that the user can select from.
    * Once a selection is made, an Open button (JButton) is enabled.
    * <ENTER> key is registered (using registerKeyboardAction()) with a JPanel which is used as the main content pane in the dialog.
    * The user can either click on the Open Button or hit the <ENTER> key which then closes the dialog and runs whatever logic that needs to.
    Now, the repaint problem comes in when:
    1. User selects an item.
    2. User hits the <ENTER> button
    3. Dialog closes
    4. User brings the dialog back up. This entails reloading the list by removing all elements from the list and adding new ones back in.
    5. Now... if the user uses the mouse to select an item lower in the list than what was done in step #1, the selection is made, but the JList doesn't repaint to show that the new selection was made.
    I didn't include a code sample because the dialog setup is totally straight-forward and I'm not doing anything trick (I've been doing this kind of thing for years now).
    If I remove the key registration for the <ENTER> key from the dialog, this problem NEVER happens. Has anyone seen anything like this? It's a minor problem since my workaround is to use a ListSelectionListener which manually calls repaint() on the JList inside the valueChanged() method.
    Just curious,
    Huy

    Oh, my bad. I'm actually using a JToggleButton and not a JButton, so the getRootPane().setDefaultButton() doesn't apply because it only takes JButton as an input param. I wonder why it wasn't implemented to take AbstractButton. hmmm.

  • Our apologies but there was an unexpected error with the application. This problem has been noted, and an email has been sent to the administrators. Please check back in a few hours to try the download again. What is

    What is going on here. I've waited 4 weeks for my ipad which will not do anything untill I've downloaded the latest version of itunes which I can't do because this message keeps appearing,
    Our apologies but there was an unexpected error with the application.
    This problem has been noted, and an email has been sent to the administrators.
    Please check back in a few hours to try the download again.
    Reading another post, someone is still trying after two days!
    Anyone got a solution to this please, or, if not, does anyone know how to email itunes.
    Thanks, Allan

    Found this
    http://www.v3.co.uk/v3-uk/download-review/1955243/apple-itunes-1011
    Hope it helps

Maybe you are looking for