Xojo Conferences
XDCMay2019MiamiUSA

Stack overflow from plugin - i'm really going nuts over this! (Real Studio Plugins Mailinglist archive)

Back to the thread list
Previous thread: Using a mac.com email address?
Next thread: Destructor with garbage parameter or without?


Re: class extensions...   -   Jan Erik Moström <
  Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
   Re: Stack overflow from plugin - i'm really going nuts over this!   -   Christian Schmitz
    Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
     Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alfred Van Hoek
      Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
       Re: Stack overflow from plugin - i'm really going nuts over this!   -   Joseph J. Strout
        Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
         Re: Stack overflow from plugin - i'm really going nuts over this!   -   Joseph J. Strout
          Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
         Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alfred Van Hoek
          Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
       Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alfred Van Hoek
        Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
         Re: Stack overflow from plugin - i'm really going nuts over this!   -   Joseph J. Strout
          Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
           Re: Stack overflow from plugin - i'm really going nuts over this!   -   Joseph J. Strout
            Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
         Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alfred Van Hoek
          Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
    Re: Stack overflow from plugin - i'm really going nuts over this!   -   Thomas Tempelmann
     Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen
    Re: Stack overflow from plugin - i'm really going nuts over this!   -   Thomas Tempelmann
    Re: Stack overflow from plugin - i'm really going nuts over this!   -   Thomas Tempelmann
     Re: Stack overflow from plugin - i'm really going nuts over this!   -   Alexander Cohen

Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 03:18 (Wed, 18 Sep 2002 22:18:13 -0400)
From: Alexander Cohen
Say i have a routine such as this one in a plugin:

void PLUGIN_DoWrite(REALcontrolInstance instance, REALobject object) {
ControlData(Control, instance, controlData, data);
ClassData(ObejctClass, object, ObjectClassData, objectData);

....
// -- here i use information defined in "objectData" and "data" and
pass them to a global routine.
// -- There is no recursion happening at all! I checked, double
checked, triple checked and, you get the idea.
// -- ex: DoSomething(data->someData, objectData->moreData);
....
}

Is it at all possible that if i call that routine many times in a
thread from RB, and i have many instances of that same thread calling
that same routine at the same time but with different objects as the
second parameter, that i could create a stack overflow?

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 03:23 (Thu, 19 Sep 2002 04:23:37 +0200)
From: Christian Schmitz
> Is it at all possible that if i call that routine many times in a
> thread from RB, and i have many instances of that same thread calling
> that same routine at the same time but with different objects as the
> second parameter, that i could create a stack overflow?

May I suggest you use DebugStr on Mac OS X to write every call to this
function into the console?

So you see when a methods is called and when it's returning.

Maybe you find the recursion problem.

PS: How much is stacksize setting for the threads?

Mfg
Christian

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 03:31 (Wed, 18 Sep 2002 22:31:11 -0400)
From: Alexander Cohen
I am not using DebugStr but i am using my own home debug system. The
method is called and returns right away, it does not do much... it's
just being called a whole lot of times from different threads. Also,
how would it be recursion if it is not calling itself, or the routines
it is calling are not calling themselves or any other routines that the
original or subsequent routines are calling?

The stack size for the RB threads are not changed. They are default. I
did try setting them much higher though, but the stack overflow is
still happening!

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 04:44 (Wed, 18 Sep 2002 23:44:23 -0400)
From: Alfred Van Hoek
on 9/18/02 10:31 PM, Alexander Cohen at <email address removed> wrote:

> I am not using DebugStr but i am using my own home debug system. The
> method is called and returns right away, it does not do much... it's
> just being called a whole lot of times from different threads. Also,
> how would it be recursion if it is not calling itself, or the routines
> it is calling are not calling themselves or any other routines that the
> original or subsequent routines are calling?

stack overflow would suggest that too many instances of something is
created. It not necessarily means a recursion. If it is called many times,
and you know the method is re-entrant, can you predict how many instances of
the object should be instantiated, and are there that many out there? It
sounds like there are many more instances then you should have. One thing
that comes in mind is: are you using a MsgBox in the thread? if so you'll
get a stack overflow, because you're not returning from the MsgBox, i.e.
you'll end up with that many MsgBoxes, the stack can hold..

Alfred

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 16:18 (Thu, 19 Sep 2002 11:18:09 -0400)
From: Alexander Cohen

> on 9/18/02 10:31 PM, Alexander Cohen at <email address removed> wrote:
>
>> I am not using DebugStr but i am using my own home debug system. The
>> method is called and returns right away, it does not do much... it's
>> just being called a whole lot of times from different threads. Also,
>> how would it be recursion if it is not calling itself, or the routines
>> it is calling are not calling themselves or any other routines that
>> the
>> original or subsequent routines are calling?
>
> stack overflow would suggest that too many instances of something is
> created. It not necessarily means a recursion. If it is called many
> times,
> and you know the method is re-entrant, can you predict how many
> instances of
> the object should be instantiated, and are there that many out there?
> It
> sounds like there are many more instances then you should have. One
> thing
> that comes in mind is: are you using a MsgBox in the thread? if so
> you'll
> get a stack overflow, because you're not returning from the MsgBox,
> i.e.
> you'll end up with that many MsgBoxes, the stack can hold..
>

You know what's funny, if i start putting message boxes and printing
out debug info into editfields, i don't get the stack overflow's! They
only happen when i'm doing something like this in my thread:

dim x as integer
do
x = x + 1
loop until x = 100

... continue other routines

if i take out the loop, i don't get the stackoverflow... i put it back
in, BAM! stack overflow!
The stack seems to overflow whenever i start doing something that
requires do be repeated many times fast!

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 16:23 (Thu, 19 Sep 2002 08:23:25 -0700)
From: Joseph J. Strout
At 11:18 AM -0400 9/19/02, Alexander Cohen wrote:

>do
> x = x + 1
>loop until x = 100
>
>... continue other routines
>
>if i take out the loop, i don't get the stackoverflow... i put it
>back in, BAM! stack overflow!

That implies that whatever's causing the overflow is in another
thread, or involves the interaction of the two threads. The loop
causes the RB code to yield, giving other threads a chance to do
their thing.

- Joe

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:15 (Thu, 19 Sep 2002 12:15:49 -0400)
From: Alexander Cohen

On Thursday, September 19, 2002, at 11:23 AM, Joseph J. Strout wrote:

> At 11:18 AM -0400 9/19/02, Alexander Cohen wrote:
>
>> do
>> x = x + 1
>> loop until x = 100
>>
>> ... continue other routines
>>
>> if i take out the loop, i don't get the stackoverflow... i put it
>> back in, BAM! stack overflow!
>
> That implies that whatever's causing the overflow is in another
> thread, or involves the interaction of the two threads. The loop
> causes the RB code to yield, giving other threads a chance to do their
> thing.
>

if i debug my threads, most of the time, i will get them starting and
ending in order:

thread1 - start
thread1 - end
thread2 - start
thread2 - end
etc...

Most of the time, they are not even running at the same time!!! So i
don't think it's the interaction between 2 threads.

How would you go receiving an event from a plugin and having to return
from the event right away and using an object passed to the event to do
something asynchronously? THat is my main purpose for using threads, if
i can get around it, that would be great. I thought of using sockets,
since they are asynchronous in nature, but the socket would sometimes
need to read from disk instead of reading from a port and i'm not sure
how that would work! I need threads!

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:20 (Thu, 19 Sep 2002 09:20:36 -0700)
From: Joseph J. Strout
At 12:15 PM -0400 9/19/02, Alexander Cohen wrote:

>How would you go receiving an event from a plugin and having to
>return from the event right away and using an object passed to the
>event to do something asynchronously?

Could you explain that in more detail?

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:33 (Thu, 19 Sep 2002 12:33:15 -0400)
From: Alexander Cohen

On Thursday, September 19, 2002, at 12:20 PM, Joseph J. Strout wrote:

> At 12:15 PM -0400 9/19/02, Alexander Cohen wrote:
>
>> How would you go receiving an event from a plugin and having to
>> return from the event right away and using an object passed to the
>> event to do something asynchronously?
>
> Could you explain that in more detail?

Sure...

I send an event to a custom control from my plugin with as a parameter,
a custom object. When the RB user receives the event, it starts up a
new instance of a custom thread class that he created and passes it the
object. The control then returns from the event.

The thread then does everything it needs to do to the custom object
(within the run event) passed to it, then terminates.

Is there any other way to do this? I need to return right away from the
control event. But i still need to use the custom object that was
passed to it, but i can't hold up the application by calling routines
on the custom object outside of a thread.

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:25 (Thu, 19 Sep 2002 12:25:39 -0400)
From: Alfred Van Hoek
on 9/19/02 12:15 PM, Alexander Cohen at <email address removed> wrote:

> How would you go receiving an event from a plugin and having to return
> from the event right away and using an object passed to the event to do
> something asynchronously? THat is my main purpose for using threads,

Ah! You need to setup something within you plugin that locks the object
when you return from the event immediately (Use a global array, or a global
linked list of objects). You then have to create another RB-event that will
message when the method+object are done. While messaging this to the user
you unlock the object to prevent leaking.

Alfred

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:37 (Thu, 19 Sep 2002 12:37:45 -0400)
From: Alexander Cohen

On Thursday, September 19, 2002, at 12:25 PM, Alfred Van Hoek wrote:

> on 9/19/02 12:15 PM, Alexander Cohen at <email address removed> wrote:
>
>> How would you go receiving an event from a plugin and having to return
>> from the event right away and using an object passed to the event to
>> do
>> something asynchronously? THat is my main purpose for using threads,
>
> Ah! You need to setup something within you plugin that locks the
> object
> when you return from the event immediately (Use a global array, or a
> global
> linked list of objects). You then have to create another RB-event
> that will
> message when the method+object are done. While messaging this to the
> user
> you unlock the object to prevent leaking.
>

I need to do this even if i don't want the plugin to keep a ref to the
object? There should never be 2 refs to the object, only 1 ref that the
user keeps until he is done with it. And i have routines that destroy
this object when the user is done with it. The user needs to call a
notify on the object, and then a destroy, and then he nils it. This is
working fine and is not leaking any memory!

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 16:37 (Thu, 19 Sep 2002 11:37:22 -0400)
From: Alfred Van Hoek
on 9/19/02 11:18 AM, Alexander Cohen at <email address removed> wrote:

> You know what's funny, if i start putting message boxes and printing
> out debug info into editfields, i don't get the stack overflow's! They
> only happen when i'm doing something like this in my thread:
>
> dim x as integer
> do
> x = x + 1
> loop until x = 100
>
> ... continue other routines
>
> if i take out the loop, i don't get the stackoverflow... i put it back
> in, BAM! stack overflow!
> The stack seems to overflow whenever i start doing something that
> requires do be repeated many times fast!

I don't know if you have setup things correctly in plugin code. Based on
the above your thread likely will return from within the loop and yield to
other threads. That's where things may go wrong. Yes, leaving out the
loop, things will run into "......continue other routines" and the critical
step is being passed.

Usage of msgBoxes I would avoid, because you cannot really stop everything,
other threads may run further messing everything up (and in your case it
messes up the other way).

Your initial post suggests that the single control instance is the method
where numerous objects are being passed too, each object being in a
different thread? Are you making sure that these objects will be destroyed
after being dealt with?

If you really want help, you should post more relevant code, we're only
guessing right now.

Alfred

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 16:54 (Thu, 19 Sep 2002 11:54:39 -0400)
From: Alexander Cohen

On Thursday, September 19, 2002, at 11:37 AM, Alfred Van Hoek wrote:

> I don't know if you have setup things correctly in plugin code. Based
> on
> the above your thread likely will return from within the loop and
> yield to
> other threads. That's where things may go wrong. Yes, leaving out the
> loop, things will run into "......continue other routines" and the
> critical
> step is being passed.
>
> Usage of msgBoxes I would avoid, because you cannot really stop
> everything,
> other threads may run further messing everything up (and in your case
> it
> messes up the other way).
>
> Your initial post suggests that the single control instance is the
> method
> where numerous objects are being passed too, each object being in a
> different thread? Are you making sure that these objects will be
> destroyed
> after being dealt with?
>
> If you really want help, you should post more relevant code, we're only
> guessing right now.
>
> Alfred

Things in my plugin are properly setup, I'm very confident in that. I'm
wondering how things can get messed up just by the loop yielding to
other threads. The threads are of the same superclass, but have nothing
in common except the control to wich they have a reference and the
routines that they call.

I am avoiding the msgbox's since they ARE messing everything up by not
provoking a stack overflow.

the RB thread class is the only holder of a reference to the object
that is being passed to the routine in the plugin. When the object has
no more ref's, it is nilled and everything is destroyed correctly. THe
plugin I am working has been around for a while now and has worked
perfectly. It's just when i started calling it from within threads in
RB that the stack overflow started happening.

I would love to post code but i'm really not sure what to post. The
plugin code will not make any sense since it calls code from a
sharedLibrary ( that i'm sure is very good, it comes from macromedia).
And the RB code won't be of much help, it's just a simple loop and a
few calls to the plugin.

Guessing is fine and i appreciate all the help that i'm getting. I know
it's hard to find a problem when you can't see what might be causing it!

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 16:59 (Thu, 19 Sep 2002 08:59:33 -0700)
From: Joseph J. Strout
At 11:54 AM -0400 9/19/02, Alexander Cohen wrote:

>I would love to post code but i'm really not sure what to post. The
>plugin code will not make any sense since it calls code from a
>sharedLibrary ( that i'm sure is very good, it comes from
>macromedia).

If the shared library code is not involved in the problem, then you
should have no trouble taking it out. Do so. Strip out absolutely
everything you can. What you can't strip out without the problem
going away, is somehow involved in the problem, and that will be a
clue. And what's left will be a simpler, easier to understand
example for us to study.

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:18 (Thu, 19 Sep 2002 12:18:37 -0400)
From: Alexander Cohen

On Thursday, September 19, 2002, at 11:59 AM, Joseph J. Strout wrote:

> At 11:54 AM -0400 9/19/02, Alexander Cohen wrote:
>
>> I would love to post code but i'm really not sure what to post. The
>> plugin code will not make any sense since it calls code from a
>> sharedLibrary ( that i'm sure is very good, it comes from >> macromedia).
>
> If the shared library code is not involved in the problem, then you
> should have no trouble taking it out. Do so. Strip out absolutely
> everything you can. What you can't strip out without the problem
> going away, is somehow involved in the problem, and that will be a
> clue. And what's left will be a simpler, easier to understand example
> for us to study.

I have stripped it down to the bare minimum... but the bare minimum is
already a lot. If anyone is willing, i will send them the code to the
plugin. It just involves a lot too much to post it here on the list.

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:22 (Thu, 19 Sep 2002 09:22:40 -0700)
From: Joseph J. Strout
At 12:18 PM -0400 9/19/02, Alexander Cohen wrote:

>I have stripped it down to the bare minimum... but the bare minimum
>is already a lot. If anyone is willing, i will send them the code to
>the plugin. It just involves a lot too much to post it here on the
>list.

Then I think you haven't stripped it down enough. You assert that
the problem is not in the shared library, so why can't you take that
out of the equation?

- Joe

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:34 (Thu, 19 Sep 2002 12:34:52 -0400)
From: Alexander Cohen

On Thursday, September 19, 2002, at 12:22 PM, Joseph J. Strout wrote:

> At 12:18 PM -0400 9/19/02, Alexander Cohen wrote:
>
>> I have stripped it down to the bare minimum... but the bare minimum
>> is already a lot. If anyone is willing, i will send them the code to
>> the plugin. It just involves a lot too much to post it here on the
>> list.
>
> Then I think you haven't stripped it down enough. You assert that the
> problem is not in the shared library, so why can't you take that out
> of the equation?
>

Because the shared library is pretty much what makes the plugin.
Without it, i have no stream and no reason to call events to my
control, and no reason to have threads that call routines on my custom
objects.

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:07 (Thu, 19 Sep 2002 12:07:14 -0400)
From: Alfred Van Hoek
on 9/19/02 11:54 AM, Alexander Cohen at <email address removed> wrote:

> Guessing is fine and i appreciate all the help that i'm getting. I know
> it's hard to find a problem when you can't see what might be causing it!

Perhaps answering the following questions may be of merit here:

Why do you want to run it in a thread? (What is the user experience without
the thread, and what should it be with a thread).

Are you sure the shared-library is re-entrant? ( Have you contacted
macromedia?)

When the stack overflow is prevented my the msgBox, what do you experience?
(does the user experience change).

The method you said returns immediately. What should happen then when you
return from it (from the sharedLib)?

I guess many more questions can be asked, but the above appears to me the
most important ones.

Alfred


---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 17:29 (Thu, 19 Sep 2002 12:29:01 -0400)
From: Alexander Cohen

On Thursday, September 19, 2002, at 12:07 PM, Alfred Van Hoek wrote:
>
> Perhaps answering the following questions may be of merit here:
>
> Why do you want to run it in a thread? (What is the user experience
> without
> the thread, and what should it be with a thread).

Here's the thing, the plugin is NPHost. It involves loading Mozilla
plugins (flash, etc...) and running them as if the plugin was mozilla.
The mozilla plugin will send you streams, i take them and create an RB
class with them and pass them to RB through an event. From that event,
the programmer keeps a ref to the stream (the only one in existence -
the moz plugin does not keep one, the RB plugin does not keep one
either) and returns from the event. Then (from a thread), the
programmer writes to the stream, then nils the stream object. The
thread is because sometimes the mozilla plugin wants the stream to be
used asynchronously. Wich means it should not do everything it wants to
do to the stream right away. The programmer stores it, returns control
to the mozllia plugin, then does whatever he needs to do to the stream.

> Are you sure the shared-library is re-entrant? ( Have you contacted
> macromedia?)

It is! I actually asked the people at netscape and they said mozilla
plugins are re-entrant and can be written to from within threads. Plus,
they said that is the right way to do it.

> When the stack overflow is prevented my the msgBox, what do you
> experience?
> (does the user experience change).

The user experiences the RB control as it is supposed to be
experienced. THey see the render of the plugin in the rb window and all
the fun stuff that goes along with using mozlla plugins. Just like they
work in Chimera, netscape, IE and mozilla.
>

> The method you said returns immediately. What should happen then when
> you
> return from it (from the sharedLib)?

Life for the shredLib goes on normally. It renders to screen, sends new
streams, etc...

>
> I guess many more questions can be asked, but the above appears to me
> the
> most important ones.

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 07:50 (Wed, 18 Sep 2002 23:50:50 -0700)
From: Thomas Tempelmann
I don't know what's going wrong for you, but pay attention
to this:

It may actually be the case that you do not have a stack
overflow, but that the code that tests for stack overflows
_believes_ that you have one.

This can happen, as it has happened just a few weeks ago with
some RbScript code under Windows.

The problem is this:

To see if the stack has overflown, a global variable must be
used that defines the limit of the stack. Now, if the SP
(Stack Pointer) goes over that limit, an overflow is assumed.
But when you deal with threads, different stacks are in use.
So, the overflow check routine must be prepared to check for
a different limit for each thread. Question is: Is this always
the case. Perhaps not, and perhaps that's the reason why you're
in this trouble. I can't tell you if that's the case or not,
because I do not know how RB does its stack overflow checking.
It may use a global var (which it may have forgotten to update
in certain cases), it may use a register that's not supposed
to be modified (but which got modified anyways in your case)
or there is a "current task" ID that points to the current
thread's info structure which contains the stack limit, and
maybe this thread ID got messed up or is not accessible
in your case.
In all cases, it could be RB's fault, and in same it could
be even yours. You might now. I don't.

That was just a thought that I had to get out of my mind before
going to bed. Now I can sleep well :^)

Thomas

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 16:14 (Thu, 19 Sep 2002 11:14:14 -0400)
From: Alexander Cohen
What do the people at RS fell about this? Do you know about anything
like this? Is this at all possible?
( These questions are mostly to programmer's at RS )

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 19:34 (Thu, 19 Sep 2002 11:34:24 -0700)
From: Thomas Tempelmann
Have you ever shown us your plugin code? Does it call back
into RB Events? If so, you should focus on that, because
there may be the problem, I'd guess.

Thomas

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 19.09.02 19:34 (Thu, 19 Sep 2002 11:34:25 -0700)
From: Thomas Tempelmann
Alexander Cohen wrote:

>The mozilla plugin will send you streams, i take them and create an RB
>class with them and pass them to RB through an event.

You are aware of the fact that you must _never_ call into RB Events
when you get a async call from somewhere? It's only safe to call
back into RB if you've been called by RB in the same flow of control
beforehand.

That means: if a plugin wants to invoke RB code through events, the
original call must have come from inside RB code, not from the
outside (i.e. a OS thread, interrupt or other async event).

If you violate that rule, it can never work stable.

Similarly, if the lib you're using does a thread scheduling, such
as switching threads while you call it, coming back under a diff
thread than you called it with, then we have already the explanation,
since this would qualify for the case of the wrong stack limit being
checked by RB as I explained yesterday (that is, because RB does not
know about the stack switch).
This thread switching is actually something well possible: If the
mozilla engine is waiting for some data in one thread, but finds that
it has received the data for another, it may just decide to switch
to that ready thread and execute it.

So, to verify this, do this: Place some thread or stack identifying
code around your calls to the suspicious Lib functions. See if the
stack pointer or thread ID remains the same. If not, you got your
problem by the neck. Solutions for this we can discuss later.
Best would be to check the stack pointer. But I do not know how
to fetch that. Perhaps with some PPC assembly, which is possible
in CW. But I do not know the details. Joe, can you suggest how to
get the current SP?

Thomas

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: Stack overflow from plugin - i'm really going nuts over this!
Date: 20.09.02 10:00 (Fri, 20 Sep 2002 05:00:23 -0400)
From: Alexander Cohen

On Thursday, September 19, 2002, at 02:34 PM, Thomas Tempelmann wrote:

> Alexander Cohen wrote:
>
>> The mozilla plugin will send you streams, i take them and create an RB
>> class with them and pass them to RB through an event.
>
> You are aware of the fact that you must _never_ call into RB Events
> when you get a async call from somewhere? It's only safe to call
> back into RB if you've been called by RB in the same flow of control
> beforehand.
>
> That means: if a plugin wants to invoke RB code through events, the
> original call must have come from inside RB code, not from the
> outside (i.e. a OS thread, interrupt or other async event).
>
> If you violate that rule, it can never work stable.
>
> Similarly, if the lib you're using does a thread scheduling, such
> as switching threads while you call it, coming back under a diff
> thread than you called it with, then we have already the explanation,
> since this would qualify for the case of the wrong stack limit being
> checked by RB as I explained yesterday (that is, because RB does not
> know about the stack switch).
> This thread switching is actually something well possible: If the
> mozilla engine is waiting for some data in one thread, but finds that
> it has received the data for another, it may just decide to switch
> to that ready thread and execute it.

The mozilla engine actually never waits for data... when the user is
done with a stream, the user uses a mozilla engine routine with some
custom data the mozilla engine gave the user when he asked for the
stream, to notify the mozilla engine of the end of the process. And i
checked this out with the mozilla programmers, everything is in the
main thread.