Re: Is this a legitimate use of ExternalAddress?
- From: "Chris Uppal" <chris.uppal@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Aug 2006 09:30:11 +0100
Jeff,
So, I've now got a new object that wraps up the ExternalCallback and
stores it in an instance variable. Simple enough. Now, the first time
the program runs (test from a worksheet), everything is perfect for the
full duration of the test. The second run (ie, hilighting the same test
code and evaluating) results in a GPF, though. Same code, same callback
block.
That definitely shouldn't happen.
On the assumption that you haven't missed anything which needs to be protected
(easy to do until you get into the habit of thinking in C while programming in
Smalltalk), it sounds like a bug in the external library which is holding onto
and using a pointer after it has been told not to (you have told it that the
pointer is now invalid ?).
One quick check would be to execute the:
MyExternalLibrary closeDefault; clear.
incantation -- which should completely unload the external library. If doing
that between two runs of your workspace test makes the problem go away, then it
is almost certainly a bug (or design misfeature) in the external library, or an
omission in the way you are driving it.
I also find it very helpful to work with VC debugging the DLL if at all
possible -- that way you can step right into the external call and
verify that pointers and other parameters that C sees are what you
expect.
I was hoping to avoid doing this (at least for now). I can see the
light at the end of the tunnel (where using Smalltalk could provide me
with great efficiency gains), but the setup getting there (at least for
external interfacing) is causing that light to dim daily. :-(
I think it depends on what you are doing. If you are attempting to connect
directly to some third party's DLL, then running that under VC could be a real
chore (unless they supply it with a working VC debug build project, etc --
which is not the typical case). OTOH, if you are connecting to your own code,
or (as I have done several times recently) to your own wrapper DLL for some
third party's non-DLL library, then it's extremely simple -- just don't exit VC
before you test your code from Dolphin ;-)
Well, OK, it a /little/ more complicated than that -- you have to tell Dolphin
to load the DLL from VC's debug folder, and tell VC to "attach" the Dolphin
process -- but I promise you that it is still pretty painless. In fact it is
rather nice -- it feels as if you are extending at least some of Smalltalk's
dynamic-ness into the static C/C++ world. I have even (just once) got
modify-and-continue to work from C++ while debugging a DLL called from
Dolphin -- the /only/ time in about 10 years that that feature has ever worked
for me...
-- chris
.
- References:
- Is this a legitimate use of ExternalAddress?
- From: Jeff M.
- Re: Is this a legitimate use of ExternalAddress?
- From: Chris Uppal
- Re: Is this a legitimate use of ExternalAddress?
- From: Jeff M.
- Is this a legitimate use of ExternalAddress?
- Prev by Date: Re: A presenter show in fullscreen
- Next by Date: Re: Where to put the resource .dll
- Previous by thread: Re: Is this a legitimate use of ExternalAddress?
- Next by thread: Where to put the resource .dll
- Index(es):
Relevant Pages
|