Re: Memory allocation and cleanup modules when using linked list
[email protected] Sun, 11 Feb 2007 08:22:46 +0100 (CET)
| Newsgroups | gmane.linux.real-time.rtlinux.general |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > Hi all, > We are doing our project in RT Linux and we have a userstart module which > will be inserted as the last one and contains the init and cleanup module. > The problem is that we are having a structure which contains a pointer as a > member and we are creating pointer to that structure. And in init module we > are allocating memory first for pointer and then for the member (pointer). > And in cleanup if we free only structure pointer then its ok but mbuff will > be occupied.But if i free member pointer first then pointer to structure then > it showing error and lsmod displays all the modules linked like this > basically I think the second method is ok freeing the member pointers and then the struct - the problem is most likely that the tasks are not synchronized and then cause a segfault by accessing the freed pointers. So what you need to do is to insert a barrier in ALL apps to sync on exit and then free the memory objects. But its hard to say without seeing the code what really is happening. Alternatively you simply build a trivial minimum module that allocates the memory for these objects as the first module to insert and clean it away as the last. hofrat -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFFzsRHnU7rXZKfY2oRAlXGAKCP0eicXYkglSMorl5tlCacCa4KFQCffW3M dqEl/WPrg0SMSDH8CP1PKPw= =WyCd -----END PGP SIGNATURE----- _______________________________________________ Rtl mailing list [email protected] http://hq.fsmlabs.com/mailman/listinfo/rtl http:/www.rtlinux-gpl.org/