edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Karl Dahlke <eklhad@comcast.net>
To: edbrowse-dev@lists.the-brannons.com
Subject: [Edbrowse-dev] Object identifiers
Date: Mon, 24 Jul 2017 02:43:28 -0400	[thread overview]
Message-ID: <20170624024328.eklhad@comcast.net> (raw)
In-Reply-To: <20170724052529.GB31626@nautica>

[-- Attachment #1: Type: text/plain, Size: 2841 bytes --]

> I'm not quite sure it will help, if the problem is a desynchronisation
> between what we think is still linked and what duktape thinks is still linked

Well if we call upon an object with id 17, and there is no such object, for any reason, we get back eb$idl[17] which will not crash the process, and is probably the null object, which is what we want.
It won't have the properties we look for, and if we try to set properties it won't do anything.
But as Chris pointed out, it will never be garbage collected away, because it always has at least one reference, our registry eb$idl[17].
That's good and bad.
We can mess with extinct objects all we want, because they're still there, but objects accumulate and never go away.
Not until you close the window.
Some web pages perform some kind of update every few seconds, like my example http://www.eklhad.net/async
and these would just accrue objects in js and tags in edbrowse for as long as the page is open.

I don't think my generated id plan is prohibitive, probably 2 or 3 days work to get it functioning.
There are advantages to that plan, and advantages to your free interceptor.
If I don't maintain a registry of objects then they will indeed go away when they should.
I only need wrapper free, because the pointer to the object is valid until it is thrown away.
But is the pointer returned by get_heapptr() the same as the base of the allocated region for that object?
Probably, but we really don't know.
It could be a structure inside the region, so malloc and free would not be the same pointers as get_heapptr and push_heapptr.
Only way to know is to write a stand-alone test program.
We'd sure want to do that before going down that path.
And hope duktape never changed that internal design.

So what to do when a pointer is freed?
Since the heap holds everything, you have to loop through all tags in all open windows in edbrowse,
and if any tag has the pointer, and there should be only one, mark it dead or otherwise delete it.
Well that's not too awful, if JS1 is set and everything is one process.
In the 2 process model it's a pain!
At an unpredictable time while javascript is running, it frees some object and we can see the pointer that is freed.
But we're in the wrong process.
I guess I'd need another side effect, pass the freed pointers back to edbrowse along with the response to whatever js function ran.
Then edbrowse can run its own version of gc as described above.

> I also think most implementations will have a way to use our own
> allocation functions

I don't believe mozilla allowed for this.
In other words, we couldn't have considered this approach last month.

> What do you think?

I tentatively like it - even though I just spent a few hours working on the generated id design...
Oh well.

Karl Dahlke

  reply	other threads:[~2017-07-24  6:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24  0:52 Karl Dahlke
2017-07-24  1:04 ` Chris Brannon
2017-07-24  5:25 ` Dominique Martinet
2017-07-24  6:43   ` Karl Dahlke [this message]
2017-07-24  7:49     ` Dominique Martinet
2017-07-24  7:03   ` Karl Dahlke
2017-07-24  5:43 ` Robert Ransom
2017-07-24 17:45   ` Adam Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170624024328.eklhad@comcast.net \
    --to=eklhad@comcast.net \
    --cc=edbrowse-dev@lists.the-brannons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).