BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

atexit and freelibrary

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Compatibility with MFC)
View previous topic :: View next topic  
Author Message
pypardo
Guest





PostPosted: Fri Oct 20, 2006 1:45 pm    Post subject: atexit and freelibrary Reply with quote



Hi,
FreeLibrary automatically call functions registered with atexit.

I don't think it's normal !

I use bcb6.0 (with allupdates).

Did somebody has information about this strange feature, and a workaround !
The only workaround I found is to avoid unloading libraries but it is not
clean enough to be used in my application.

Best regards
pierre
Back to top
Ed Mulroy
Guest





PostPosted: Fri Oct 20, 2006 11:37 pm    Post subject: Re: atexit and freelibrary Reply with quote



Quote:
FreeLibrary automatically call functions registered with atexit.

No it does not. FreeLibrary is a function supplied in an external DLL by
Windows and has no idea of the functions registered with atexit.

Look at the program again. Something else is wrong. You might start by
checking the value of the module handle used in the call to FreeLibrary.

.. Ed

Quote:
pypardo wrote in message
news:XnF98626D12DFF7Bpypardonospamgmailco (AT) 207 (DOT) 105.83.66...
Hi,
FreeLibrary automatically call functions registered with atexit.

I don't think it's normal !

I use bcb6.0 (with allupdates).

Did somebody has information about this strange feature, and
a workaround ! The only workaround I found is to avoid unloading
libraries but it is not clean enough to be used in my application.
Back to top
pypardo
Guest





PostPosted: Mon Oct 23, 2006 1:52 pm    Post subject: Re: atexit and freelibrary Reply with quote



"Ed Mulroy" <dont_email_me (AT) bitbuc (DOT) ket> écrivait
news:45391768$1 (AT) newsgroups (DOT) borland.com:

Quote:
FreeLibrary automatically call functions registered with atexit.

No it does not. FreeLibrary is a function supplied in an external DLL
by Windows and has no idea of the functions registered with atexit.

Look at the program again. Something else is wrong. You might start
by checking the value of the module handle used in the call to
FreeLibrary.

. Ed

Hi,

I can confirm this problem.

I create a simple project, with just an atexit function at the begining.
And 2 buttons (loadlibrary and freelibrary).
I push loadlibrary button, and then freelibrary button.
When freelibrary is called, the function registered in atexit is called !!!

I can send my project if needed (maybe in borland.public.attachements ?).

I use BCB6.0, and my program/library are compiled with use of the rtl.

Best regards
pierre.
Back to top
pypardo
Guest





PostPosted: Mon Oct 23, 2006 2:00 pm    Post subject: Re: atexit and freelibrary Reply with quote

"Ed Mulroy" <dont_email_me (AT) bitbuc (DOT) ket> écrivait
news:45391768$1 (AT) newsgroups (DOT) borland.com:

Quote:
FreeLibrary automatically call functions registered with atexit.

No it does not. FreeLibrary is a function supplied in an external DLL
by Windows and has no idea of the functions registered with atexit.

Look at the program again. Something else is wrong. You might start
by checking the value of the module handle used in the call to
FreeLibrary.

. Ed
Hi,

here're more information:

This problem only occurs when I use dynamic RTL.

I really think it's a BUG, because registered function in atexit() MUST be
called at the exit of the program and not during a freelibrary process.
One more thing, registered function are only called once: during
freelibrary, they are called, but they are not called when program exit !!!

Is there a workaround or patch for this ?

Best regards
Back to top
Ed Mulroy
Guest





PostPosted: Mon Oct 23, 2006 8:16 pm    Post subject: Re: atexit and freelibrary Reply with quote

Quote:
I can send my project if needed (maybe in borland.public.
attachements ?).

Before you do that, select Help|About in the IDE. Confirm that you are
using build number 10.166 If you are not then go get and apply the compiler
updates and try again.

If you zip up the project and post it borland.public.attachments, I will
look at it. Be careful to include everything the project needs except for
items which came with the compiler.

.. Ed

Quote:
pypardo wrote in message
news:XnF98656E5CBFC29pypardonospamgmailco (AT) 207 (DOT) 105.83.66...

I can confirm this problem.

I create a simple project, with just an atexit function at the begining.
And 2 buttons (loadlibrary and freelibrary).
I push loadlibrary button, and then freelibrary button.
When freelibrary is called, the function registered in atexit is called
!!!

I can send my project if needed (maybe in borland.public.attachements ?).

I use BCB6.0, and my program/library are compiled with use of the rtl.

Best regards
pierre.
Back to top
pypardo
Guest





PostPosted: Mon Oct 23, 2006 8:55 pm    Post subject: Re: atexit and freelibrary Reply with quote

"Ed Mulroy" <dont_email_me (AT) bitbuc (DOT) ket> écrivait
news:453cdd6d$1 (AT) newsgroups (DOT) borland.com:

Quote:
I can send my project if needed (maybe in borland.public.
attachements ?).

Before you do that, select Help|About in the IDE. Confirm that you
are using build number 10.166 If you are not then go get and apply
the compiler updates and try again.

If you zip up the project and post it borland.public.attachments, I
will look at it. Be careful to include everything the project needs
except for items which came with the compiler.

. Ed

Hi Ed,
thanks for informations.
I can confirm this problem with a sample project and when I use dynamic
RTL.
I also put an entry in borland quality central
http://qc.borland.com/wc/qcmain.aspx?d=35585

I upload my sample project in borland.public.attachments (the name is
ateit and freelibrary).
It's easy to control the way the registered functions are called (I use
OutputDebugString).

=>When project and library are compiled with dynamic RTL, atexit
registered functions are called when freelibrary is call (and not at the
end of the program).
=>When project and library are compiled without dynamic RTL, atexit
registered functions are called only at the end of the program.

best regards
pierre

Quote:

pypardo wrote in message
news:XnF98656E5CBFC29pypardonospamgmailco (AT) 207 (DOT) 105.83.66...

I can confirm this problem.

I create a simple project, with just an atexit function at the
begining. And 2 buttons (loadlibrary and freelibrary).
I push loadlibrary button, and then freelibrary button.
When freelibrary is called, the function registered in atexit is
called !!!

I can send my project if needed (maybe in borland.public.attachements
?).

I use BCB6.0, and my program/library are compiled with use of the
rtl.

Best regards
pierre.


Back to top
Ed Mulroy
Guest





PostPosted: Mon Oct 23, 2006 10:47 pm    Post subject: Re: atexit and freelibrary Reply with quote

You have some problems that need to be corrected.

The value of the handle returned by the call to LoadLibrary is not checked
for NULL. The function is passed to atexit three times, at least one of
which is related to using that handle but the value is never checked. It
should only be passed to atexit once. The value of the handle is not set to
NULL after calling FreeLibrary and not checked for NULL prior to calling
FreeLibrary.

.. Ed

Quote:
pypardo wrote in message
news:XnF98656F9A7DAC1pypardonospamgmailco (AT) 207 (DOT) 105.83.66...
Back to top
pypardo
Guest





PostPosted: Tue Oct 24, 2006 7:04 pm    Post subject: Re: atexit and freelibrary Reply with quote

"Ed Mulroy" <dont_email_me (AT) bitbuc (DOT) ket> écrivait
news:453d0045 (AT) newsgroups (DOT) borland.com:

Quote:
You have some problems that need to be corrected.

The value of the handle returned by the call to LoadLibrary is not
checked for NULL. The function is passed to atexit three times, at
least one of which is related to using that handle but the value is
never checked. It should only be passed to atexit once. The value of
the handle is not set to NULL after calling FreeLibrary and not
checked for NULL prior to calling FreeLibrary.

. Ed

pypardo wrote in message
news:XnF98656F9A7DAC1pypardonospamgmailco (AT) 207 (DOT) 105.83.66...



Hi,
The problem is NOT that the freelibrary is applied on a NULL pointer. And
this small program (in borland.public.attachments) is just a sample to
reproduce the problem, it's not our real program.
The problem is THAT a call to freelibrary call functions registered by
atexit method.

This problem only occurs when dynamic RTL is used.

Best regards
pierre
Back to top
Ed Mulroy
Guest





PostPosted: Tue Oct 24, 2006 8:29 pm    Post subject: Re: atexit and freelibrary Reply with quote

So you are suggesting that I debug and fix the example code you posted and
then try to use it to explain what is happening in the program which you did
not provide?

Fix the problems I mentioned in the target code that you did not provide.
After that you can look to see if the problem still occurs.

Also note that calling FreeLibrary on an invalid pointer (not just on a NULL
one) is only one of the problem items I mentioned.

.. Ed

Quote:
pypardo wrote in message
news:XnF9866A328CFBE5pypardonospamgmailco (AT) 207 (DOT) 105.83.66...

Hi,
The problem is NOT that the freelibrary is applied on a NULL pointer. And
this small program (in borland.public.attachments) is just a sample to
reproduce the problem, it's not our real program.
The problem is THAT a call to freelibrary call functions registered by
atexit method.

This problem only occurs when dynamic RTL is used.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Compatibility with MFC) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.