Discussion:
[drlvm][thread] stacksize
Pierre Queinnec
2011-04-21 20:13:56 UTC
Permalink
Hi guys,

I'm seeing some strange thread stack size behavior while porting to Mac, and I've been trying to compare to a build on a 64bit linux (Debian 6).

Here's what I see on Linux, whatever I can define for my Xss, the stack size in init_psd_structure always calculates 8M :

==========================================================================
***@squeezy:~/Code/harmony-svn-java6/target/hdk/jdk$ ./bin/java -Xmx1024m -Xss12m -version
init_psd_structure: stack_size = 8388608
init_psd_structure: guard_size = 4096
init_psd_structure: mem_protect_size = 1024
PMQ - setup_stack - (&res - mem_protect_size) = 140736255271036
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140736246960128
PMQ - setup_stack - (&res - mem_protect_size) = 140715543796204
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715541778432
PMQ - setup_stack - (&res - mem_protect_size) = 140715528108524
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715515604992
PMQ - setup_stack - (&res - mem_protect_size) = 140715515521516
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715513503744
PMQ - setup_stack - (&res - mem_protect_size) = 140715513420268
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715511402496
Apache Harmony Launcher : (c) Copyright 1991, 2010 The Apache Software Foundation or its licensors, as applicable.
java version "1.5.0"
Apache Harmony (1.5.0)
DRLVM (1.5.0-r1092753)
pre-alpha : not complete or compatible
svn = r1092753, (Apr 15 2011), Linux/em64t/gcc 4.4.5, release build
http://harmony.apache.org
==========================================================================

(patch attached, maybe I just missed something obvious... I've seen some maybe related JIRA but they were supposed to be closed)

As a second question, in drlvm/vm/port/src/thread/linux/thread_os.c there's this test :

if ((size_t)(&res) - PSD->mem_protect_size
< (size_t)tlsdata->guard_page_addr + tlsdata->guard_page_size)
return EINVAL;

I'm not sure I get this... Anyone care to explain?

As a side note, the port seems to start fine but crashes after starting some threads.
Cheers,
-- Pierre Queinnec
Alexei Fedotov
2011-04-21 20:45:55 UTC
Permalink
Pierre,

Please try the following searches:

The parameter is set:
http://www.google.com/codesearch?q="thread.stacksize"&exact_package=http%3A%2F%2Fsvn.apache.org%2Frepos%2Fasf%2Fharmony%2Fenhanced%2F<http://www.google.com/codesearch?q=%22thread.stacksize%22&exact_package=http%3A%2F%2Fsvn.apache.org%2Frepos%2Fasf%2Fharmony%2Fenhanced%2F>

The thread is created:
http://www.google.com/codesearch?lr=&q="port_thread_create"&sbtn=ППОск&exact_package=http%3A%2F%2Fsvn.apache.org%2Frepos%2Fasf%2Fharmony%2Fenhanced%2F<http://www.google.com/codesearch?lr=&q=%22port_thread_create%22&sbtn=%D0%9F%D0%BE%D0%B8%D1%81%D0%BA&exact_package=http%3A%2F%2Fsvn.apache.org%2Frepos%2Fasf%2Fharmony%2Fenhanced%2F>

Maybe if you add more debugging there, this will help.

--
With best regards / с МаОлучшОЌО пПжелаМОяЌО,
Alexei Fedotov / Алексей ЀеЎПтПв,
http://dataved.ru/
+7 916 562 8095



On Fri, Apr 22, 2011 at 12:13 AM, Pierre Queinnec <
Post by Pierre Queinnec
Hi guys,
I'm seeing some strange thread stack size behavior while porting to Mac,
and I've been trying to compare to a build on a 64bit linux (Debian 6).
Here's what I see on Linux, whatever I can define for my Xss, the stack
==========================================================================
-Xmx1024m -Xss12m -version
init_psd_structure: stack_size = 8388608
init_psd_structure: guard_size = 4096
init_psd_structure: mem_protect_size = 1024
PMQ - setup_stack - (&res - mem_protect_size) = 140736255271036
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140736246960128
PMQ - setup_stack - (&res - mem_protect_size) = 140715543796204
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715541778432
PMQ - setup_stack - (&res - mem_protect_size) = 140715528108524
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715515604992
PMQ - setup_stack - (&res - mem_protect_size) = 140715515521516
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715513503744
PMQ - setup_stack - (&res - mem_protect_size) = 140715513420268
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715511402496
Apache Harmony Launcher : (c) Copyright 1991, 2010 The Apache Software
Foundation or its licensors, as applicable.
java version "1.5.0"
Apache Harmony (1.5.0)
DRLVM (1.5.0-r1092753)
pre-alpha : not complete or compatible
svn = r1092753, (Apr 15 2011), Linux/em64t/gcc 4.4.5, release build
http://harmony.apache.org
==========================================================================
(patch attached, maybe I just missed something obvious... I've seen some
maybe related JIRA but they were supposed to be closed)
if ((size_t)(&res) - PSD->mem_protect_size
< (size_t)tlsdata->guard_page_addr + tlsdata->guard_page_size)
return EINVAL;
I'm not sure I get this... Anyone care to explain?
As a side note, the port seems to start fine but crashes after starting some threads.
Cheers,
-- Pierre Queinnec
Ilya Berezhniuk
2011-04-26 02:43:05 UTC
Permalink
Hi Pierre,

1) The stack size you see is most probably a main thread stack size,
obtained once the global instance of "port shared data" object is
created, while attaching main thread to the port threading system.
You cannot change main thread stack size via Xss, it's set up in
compile time I believe.

To get size of all managed threads created by the VM, you can examine
results returned by the call to find_stack_addr_size() in init_stack()
function (vm/port/src/thread/linux/thread_os.c:395).

2) The meaning of the test is to check if our current stack position
(obtained through getting an address of local variable) with a fixed
spare space (mem_protect_size) overlaps with an area which is to be
protected by set_guard_page() later in this function. If they do
overlap, then we have way too small stack to work properly, even less
than 0x400 (0x100 on 32-bit) bytes between current stack and special
area supposed for catching stack overflow.

Thanks,
Ilya.




On Thu, Apr 21, 2011 at 1:45 PM, Alexei Fedotov
Post by Alexei Fedotov
Pierre,
http://www.google.com/codesearch?q="thread.stacksize"&exact_package=http%3A%2F%2Fsvn.apache.org%2Frepos%2Fasf%2Fharmony%2Fenhanced%2F<http://www.google.com/codesearch?q=%22thread.stacksize%22&exact_package=http%3A%2F%2Fsvn.apache.org%2Frepos%2Fasf%2Fharmony%2Fenhanced%2F>
http://www.google.com/codesearch?lr=&q="port_thread_create"&sbtn=Поиск&exact_package=http%3A%2F%2Fsvn.apache.org%2Frepos%2Fasf%2Fharmony%2Fenhanced%2F<http://www.google.com/codesearch?lr=&q=%22port_thread_create%22&sbtn=%D0%9F%D0%BE%D0%B8%D1%81%D0%BA&exact_package=http%3A%2F%2Fsvn.apache.org%2Frepos%2Fasf%2Fharmony%2Fenhanced%2F>
Maybe if you add more debugging there, this will help.
--
With best regards / с наилучшими пожеланиями,
Alexei Fedotov / Алексей Федотов,
http://dataved.ru/
+7 916 562 8095
On Fri, Apr 22, 2011 at 12:13 AM, Pierre Queinnec <
Post by Pierre Queinnec
Hi guys,
I'm seeing some strange thread stack size behavior while porting to Mac,
and I've been trying to compare to a build on a 64bit linux (Debian 6).
Here's what I see on Linux, whatever I can define for my Xss, the stack
==========================================================================
-Xmx1024m -Xss12m -version
init_psd_structure: stack_size = 8388608
init_psd_structure: guard_size = 4096
init_psd_structure: mem_protect_size = 1024
PMQ - setup_stack - (&res - mem_protect_size) = 140736255271036
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140736246960128
PMQ - setup_stack - (&res - mem_protect_size) = 140715543796204
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715541778432
PMQ - setup_stack - (&res - mem_protect_size) = 140715528108524
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715515604992
PMQ - setup_stack - (&res - mem_protect_size) = 140715515521516
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715513503744
PMQ - setup_stack - (&res - mem_protect_size) = 140715513420268
PMQ - setup_stack - (guard_page_addr + guard_page_size = 140715511402496
Apache Harmony Launcher : (c) Copyright 1991, 2010 The Apache Software
Foundation or its licensors, as applicable.
java version "1.5.0"
Apache Harmony (1.5.0)
DRLVM (1.5.0-r1092753)
pre-alpha : not complete or compatible
svn = r1092753, (Apr 15 2011), Linux/em64t/gcc 4.4.5, release build
http://harmony.apache.org
==========================================================================
(patch attached, maybe I just missed something obvious... I've seen some
maybe related JIRA but they were supposed to be closed)
     if ((size_t)(&res) - PSD->mem_protect_size
             < (size_t)tlsdata->guard_page_addr + tlsdata->guard_page_size)
         return EINVAL;
I'm not sure I get this... Anyone care to explain?
As a side note, the port seems to start fine but crashes after starting some threads.
Cheers,
-- Pierre Queinnec
Loading...