 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
infernal Guest
|
Posted: Sat Mar 12, 2005 6:15 pm Post subject: huge problem: class methods = ???? |
|
|
hi,
I have an application which AV's on me.
It is quite big so i cant post the code, ive been debugging on it for days -
and have seen something which i really cant understand.
The program is an EXE file, which dynamically loads DLL's - and the DLL has
an exported class - based on similar approach as in this thread:
http://groups.google.dk/groups?hl=da&lr=&threadm=3e84190d%40newsgroups.borland.com&rnum=1&prev=/groups%3Fq%3Dhttp://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20562300.html%26hl%3Dda%26lr%3D%26selm%3D3e84190d%2540newsgroups.borland.com%26rnum%3D1
Anyway it is working okay - normally, there is some issues though - and one
of the ive seen in my debugging, is inspecting the class pointer to the DLL
class.
When the AV comes, i can see that the class has all its variables and its
own classes initiated fine, but the memberfunctions is all: ?????? (which
means they dont have a memoryaddress - somehow not created ?).
Which ofcourse creates the AV, because the program is calling a function
which doesnt have a memory address.
The mysterious part is that it is only happening sometimes, its not
everytime the code is run - in my testing im loading, and reloading the DLL
continously.
What i suspect is that somewhere in the routine where i load the DLL it goes
wrong:
hLibrary = (HINSTANCE)::LoadLibrary( "line.dll" );
if (hLibrary!=NULL)
{
getclassplugin = (GETCLASSPLUGIN) GetProcAddress( hLibrary,
"_LineGetClass" );
setclassplugin = (SETCLASSPLUGIN) GetProcAddress( hLibrary,
"_LineSetClass" );
setclassplugin( (long)( this ) );
if (getclassplugin!=NULL)
{
lineDLL = NULL;
getclassplugin( &lineDLL );
if (lineDLL != NULL)
{
lineDLL->Create();
LineLoaded ( true );
}
}
}
As you can see ive tried to protect myself by checking on NULL's - but they
are always != NULL, so it should be alright - but apparently something goes
wrong.
Anyway - do any of you know how a class can be initiated with variables, and
class inside the variable segment - but memberfunctions arent created ?
Really hope you can help here :(
|
|
| Back to top |
|
 |
Ed Mulroy [TeamB] Guest
|
Posted: Sat Mar 12, 2005 8:18 pm Post subject: Re: huge problem: class methods = ???? |
|
|
One thing I see:
| Quote: | hLibrary = (HINSTANCE)::LoadLibrary( "line.dll" );
if (hLibrary!=NULL)
{
getclassplugin = (GETCLASSPLUGIN) GetProcAddress( hLibrary,
"_LineGetClass" );
setclassplugin = (SETCLASSPLUGIN) GetProcAddress( hLibrary,
"_LineSetClass" );
setclassplugin( (long)( this ) ); <====HERE
if (getclassplugin!=NULL)
|
Used without checking for NULL.
.. Ed
| Quote: | infernal wrote in message
news:42333211 (AT) newsgroups (DOT) borland.com...
I have an application which AV's on me.
It is quite big so i cant post the code, ive been debugging on it
for days - and have seen something which i really cant understand.
The program is an EXE file, which dynamically loads DLL's - and the
DLL has an exported class - based on similar approach as in this
thread:
http://groups.google.dk/groups?hl=da&lr=&threadm=3e84190d%40newsgroups.borland.com&rnum=1&prev=/groups%3Fq%3Dhttp://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20562300.html%26hl%3Dda%26lr%3D%26selm%3D3e84190d%2540newsgroups.borland.com%26rnum%3D1
Anyway it is working okay - normally, there is some issues though -
and one of the ive seen in my debugging, is inspecting the class
pointer to the DLL class.
When the AV comes, i can see that the class has all its variables
and its own classes initiated fine, but the memberfunctions is all:
?????? (which means they dont have a memoryaddress - somehow not
created ?).
Which ofcourse creates the AV, because the program is calling a
function which doesnt have a memory address.
The mysterious part is that it is only happening sometimes, its not
everytime the code is run - in my testing im loading, and reloading
the DLL continously.
What i suspect is that somewhere in the routine where i load the DLL
it goes wrong:
hLibrary = (HINSTANCE)::LoadLibrary( "line.dll" );
if (hLibrary!=NULL)
{
getclassplugin = (GETCLASSPLUGIN) GetProcAddress( hLibrary,
"_LineGetClass" );
setclassplugin = (SETCLASSPLUGIN) GetProcAddress( hLibrary,
"_LineSetClass" );
setclassplugin( (long)( this ) );
if (getclassplugin!=NULL)
{
lineDLL = NULL;
getclassplugin( &lineDLL );
if (lineDLL != NULL)
{
lineDLL->Create();
LineLoaded ( true );
}
}
}
As you can see ive tried to protect myself by checking on NULL's -
but they are always != NULL, so it should be alright - but
apparently something goes wrong.
Anyway - do any of you know how a class can be initiated with
variables, and class inside the variable segment - but
memberfunctions arent created ?
Really hope you can help here
|
|
|
| Back to top |
|
 |
infernal Guest
|
Posted: Sat Mar 12, 2005 8:33 pm Post subject: Re: huge problem: class methods = ???? |
|
|
Hi Ed,
Youre right - i didnt test setclassplugin pointer for NULL.
This still didnt fixed it though - and breakpointing it shows that i never
get a setclassplugin which is NULL :(
Im very puzzled about this class which dont have their memberfunctions
allocated - im looking into using the Win32 function:
FBadReadPtr() to check the areas where i get the AV - but in the case of the
memberfunctions i cant use it (cant get an address of a function apparently)
do you know how to ?
"Ed Mulroy [TeamB]" <dont_email_me (AT) invalid (DOT) com> skrev i en meddelelse
news:42334ea6$1 (AT) newsgroups (DOT) borland.com...
| Quote: | One thing I see:
hLibrary = (HINSTANCE)::LoadLibrary( "line.dll" );
if (hLibrary!=NULL)
{
getclassplugin = (GETCLASSPLUGIN) GetProcAddress( hLibrary,
"_LineGetClass" );
setclassplugin = (SETCLASSPLUGIN) GetProcAddress( hLibrary,
"_LineSetClass" );
setclassplugin( (long)( this ) ); <====HERE
if (getclassplugin!=NULL)
Used without checking for NULL.
. Ed
|
|
|
| Back to top |
|
 |
infernal Guest
|
Posted: Sat Mar 12, 2005 10:22 pm Post subject: Re: huge problem: class methods = ???? |
|
|
think ive solved the problem - i did 2 freelibrary before doing
loadlibrary() when i reloaded the DLL, which i strongly suspect would mess
up my referencecount - thereby the breakdowns ive experineced.
Been running my test for 30 minutes now on huge load, with no problems -
with that load it wasnt able to run 10 seconds before :)
12 hours of debugging today - but now its all worth it :)
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|