It seems that problem was localized in staff class JavaStringBuffer.
The class has inline implementation in jdk\src\windows\native\sun\windows\awt.h

The right code is:

class JavaStringBuffer
{
protected:
    LPWSTR m_pStr;
    jsize  m_dwSize;
    LPWSTR getNonEmptyString() {
        return (NULL==m_pStr)
                ? L""
                : m_pStr;
    }

public:
    JavaStringBuffer(jsize cbTCharCount) {
        m_dwSize = cbTCharCount;
        m_pStr = (LPWSTR)safe_Malloc( (m_dwSize+1)*sizeof(WCHAR) );
    }

    JavaStringBuffer(JNIEnv *env, jstring text) {
        if (NULL == text) {
            m_pStr = NULL;
            m_dwSize = 0;
        } else {
            m_dwSize = env->GetStringLength(text);
            m_pStr = (LPWSTR)safe_Malloc( (m_dwSize+1)*sizeof(WCHAR) );
env->GetStringRegion(text, 0, m_dwSize, reinterpret_cast<jchar *>(m_pStr));
            m_pStr[m_dwSize] = 0;
        }
    }

    ~JavaStringBuffer() {
        free(m_pStr);
    }

    void Resize(jsize cbTCharCount) {
        m_dwSize = cbTCharCount;
        m_pStr = (LPWSTR)safe_Realloc(m_pStr, (m_dwSize+1)*sizeof(WCHAR) );
    }
    //we are in UNICODE now, so LPWSTR:=:LPTSTR
    operator LPWSTR() { return getNonEmptyString(); }
    operator LPARAM() { return (LPARAM)getNonEmptyString(); }
    void *GetData() { return (void *)getNonEmptyString(); }
    jsize  GetSize() { return m_dwSize; }
};

That solves the problem.
Regards,
-uta

On 7/15/2010 17:54, Artem Ananiev wrote:

-------- Original Message --------
Subject: Re: <AWT Dev> VM hangs in VS2008 build
Date: Tue, 13 Jul 2010 09:15:12 -0700
From: Phil Race <philip.r...@oracle.com>
To: Artem Ananiev <artem.anan...@sun.com>

FYI your test crashes with my VS2010 build on Windows 7, apparently
also when trying to dispose. Windows whinges about corrupted (C) heap.
The break point opened by Visual Studio is inside msvcr100.dll at

static unsigned long WINAPI _threadstartex () ->
  ..
     _callthreadstartex(); // here.

-phil.

On 7/13/2010 4:56 AM, Artem Ananiev wrote:
Hi, AWT & HotSpot teams,

I've just experienced a problem with a simple test - see the attached
file. The test shows a file dialog and then hangs when the dialog is
being disposed. I tried to get a stack trace... and failed, both with
jstack and ctrl+break from the console.

When I attached to the process with Visual Studio, I noticed several
suspicious threads:

1. One of the threads with AWT code waits for safe_Malloc() to return,
which in turn waits for JVM code in Monitor::set_owner_implementation():

 ntdll.dll!_zwwaitforsingleobj...@12()
 ntdll.dll!_zwwaitforsingleobj...@12()
 jvm.dll!Monitor::set_owner_implementation(Thread *
new_owner=0x00000000)  Line 1307
 ntdll.dll!_rtlentercriticalsect...@4()
 ntdll.d...@rtlpallocateheap@24()
 ntdll.dll!_rtlallocateh...@12()
 msvcr90.dll!75293db8()
 [Frames below may be incorrect and/or missing, no symbols loaded for
msvcr90.dll]
 awt.dll!safe_Malloc(unsigned int size=6)  Line 85
 awt.dll!CreateLocaleObject(JNIEnv_ * env=0x04601d34, const char *
name=0x002a1e58)  Line 539
 awt.dll!Java_sun_awt_windows_WInputMethod_getNativeLocale(JNIEnv_ *
env=0x04601d34, _jclass * cls=0x065bf728)  Line 299


2. Another thread is in os::free():

 ntdll.dll!_zwwaitforsingleobj...@12()
 ntdll.dll!_zwwaitforsingleobj...@12()
 kernelbase.dll!_getprocaddr...@8()
 ntdll.dll!_rtlentercriticalsect...@4()
 ntdll.d...@rtlpfreeheap@16()
 ntdll.dll!_rtlfreeh...@12()
 kernel32.dll!_heapf...@12()
 msvcr90.dll!75293c1b()
 [Frames below may be incorrect and/or missing, no symbols loaded for
msvcr90.dll]
 jvm.dll!os::free(void * memblock=0x01f64d50)  Line 602
 jvm.dll!ChunkPool::free_all_but(unsigned int n=5)  Line 152
 jvm.dll!ChunkPoolCleaner::task()  Line 195
 jvm.dll!PeriodicTask::real_time_tick(unsigned int delay_time=50)
Line 60
 jvm.dll!WatcherThread::run()  Line 1086
 jvm.dll!java_start(Thread * thread=0x01f5c800)  Line 377


3. One more thread waiting for a memory-related operation - I suspect
it's the thread that should provide the stack trace:

 ntdll.dll!_zwwaitforsingleobj...@12()
 ntdll.dll!_zwwaitforsingleobj...@12()
 jvm.dll!InterfaceSupport::serialize_memory(JavaThread *
thread=0x00000148)  Line 37
 kernel32.dll!_waitforsingleobjecteximplementat...@12()
 kernel32.dll!_waitforsingleobj...@8()
 jvm.dll!Win32AttachListener::dequeue()  Line 233
 jvm.dll!AttachListener::dequeue()  Line 353
 jvm.dll!attach_listener_thread_entry(JavaThread * thread=0x01f4d800,
Thread * __the_thread__=0x01f4d800)  Line 376
 jvm.dll!JavaThread::thread_main_inner()  Line 1402
 jvm.dll!java_start(Thread * thread=0x01f4d800)  Line 377


Any ideas about what's going? The hang only occurs if I build JDK and
HotSpot using VS2008 - exactly the same JDK7-b99 promoted build (which
is built with VS2003) works fine. If I change the file dialog with a
regular AWT modal dialog, the problem goes away as well.

Thanks,

Artem



Reply via email to