This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Cygwin.dll crash, alloca and custom stack


From: "Gary R. Van Sickle  wrote:
>In the post you're replying to, I listed the legitimate reasons for wanting
>to do it.  Here they are again:
>
>- If you're writing a task switcher.

And what's the difference between a task switcher and switching 
between co-routines? Basically nothing at all except that a task gets
switched
whenever the OS wants to, whereas a co-routine gets switched under program
control. So why must they be implemented differently? It's nothing new to be
writing
user space task switchers that switch stacks, I see no reason why a user
space co-routine switcher should not do the same.

>Do you actually realize that there are far better ways to implement stacks
>for interpreters than dinking with esp?

I realise there are a dozen ways to suck eggs. But do YOU realise that there

are two ways to implement a language with co-routines, whether it be
interpreted
or compiled, and that is to either have a vm with a fake stack, or to use
the
machine's real stack. And if you use the machine's real stack you MUST
"dink" with 
esp. You MUST. I don't happen to be writing a VM based interpreter with
a fake stack.

>I suggest you investigate those alternatives instead of trying to
>do something that cannot work, and then getting all pissy when people try
to
>dissuade you from wasting your time. 

That's strange. Now that I know that on Windows it likes to use its own
stack for system calls, its working fine by just restoring the system stack
temporarily. I can switch stacks and co-routines with no problems at all. So
much for your bogus "cannot work". I guess you don't know everything after
all huh? I do remain curious why Windows actually cares whereas Linux acts
sensibly and doesn't carebut it matters little for my purposes. 

>No, but there is a law that you have to learn to walk before you can run.
>You are trying to sprint a marathon before you're even able to stand erect.


Meaningless ad-hominem. I guess now that I've got it working, if I can't
stand erect, you must not even be crawling. 

>Christopher Faylor <cgf-no-personal-reply-please at cygwin dot com> wrote:
>What you are trying to do is a bad idea.  

Bad huh? I'm fuzzy on the whole good/bad thing. Care to elaborate? 

>Btw, have you thought about how to handle stack overflow?  What happens
>when the program pushes its way to the top of your malloced region?  

Each Scheme function call has its own environment that is chained to
previous environments. Each environment has its own stack. The C code that
executes a scheme function uses a small and well-defined amount of stack.
Restoring the system stack for external library calls is going to be a good
idea anyway, because they can use arbitrary amounts of stack. But for the
interpreter itself the exact amount of stack required for one lambda can be
calculated by trial and error. The other way to implement it is to copy
the entire stack when switching co-routines, but I'm trying to avoid that.

-----------------------------------------------------------------
If you have received this transmission in error please notify us 
immediately by return e-mail and delete all copies. If this e-mail 
or any attachments have been sent to you in error, that error does 
not constitute waiver of any confidentiality, privilege or copyright 
in respect of information in the e-mail or attachments. 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]