Re: [rvm-research] Potential issues with longjmp in bootImageRunner

Carl Ritson <[email protected]>
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <CAKDym5PTd0tjO2RA3G22vFpoVNRsAhu77ZUiT-keEJeKwwPOpA@mail.gmail.com>
>>> There are a number of approaches to dealing with this:
>>>  1. assume allocation will always be top-down and ignore,
>>>  2. explicitly allocate thread stacks (these can be passed to pthread_create),
>>>  3. replace use of setjmp/longjmp with savecontext/swapcontext
>>> (although these are deprecated in POSIX),
>>>  4. implement a local version of longjmp without a check,
>>>  5. bypass the __longjmp_chk by using glibc's internal __libc_longjmp().
>>>
>>> Disregarding (1), (5) is the smallest change set.
>>
>> I'd also disregard (1). (3) and (4) don't seem attractive to me; we
>> ought to rely on non-deprecated methods from the system libraries as
>> much as possible.
>
> My opinion is (3) the best option as (2) requires the bootImageRunner
> to allocate memory at a specific place in memory and manage it
> (because thread heap will need to be freed).  Instead of
> reimplementing setjmp/longjmp completely, bootThread already has to be
> implemented in machine specific assembly to pivot the stack when
> entering the VM, the existing code should hence be extended to allow
> for pivoting back onto the thread stack.  In effect bootThread should
> return when sysThreadTerminate is called.

It has been pointed out to me that where I said (3), I meant (4).  I
agree that the use of deprecated APIs is not a good option.  An
possible extension to (2) is to use the explicitly allocated stacks
from inside the VM and entirely bypass the allocated of thread stacks
in C/C++.  Although issues regarding the primordial thread would still
need to be addressed.

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.