TIP: Click on subject to list as thread! ANSI
echo: fidosoft.husky
to: andrew clarke
from: Michael Dukelsky
date: 2021-03-12 15:29:00
subject: Htick Hatching

Hello andrew,

Friday March 12 2021, andrew clarke wrote to Michael Dukelsky:

 PH>>>>> double free or corruption (fasttop)
 PH>>>>> Aborted

 ac>>> This is likely due to free() being called twice on the same
 ac>>> pointer somewhere in the Linux build of HTick.

 MD>> OK, thank you. It should be easy to fix.

 ac> nfree() may help but it's not foolproof. Consider this:

 ac> #include 
 ac> #include 
 ac> #include 

 ac> #define nfree(a) {if(a != NULL) {free(a); a = NULL;}}

 ac> static void foo(char *p)
 ac> {
 ac>     printf("%s\n", p);
 ac>     nfree(p);
 ac> }

 ac> int main(void)
 ac> {
 ac>     char *p = malloc(42);
 ac>     strcpy(p, "Hello!");
 ac>     foo(p);
 ac>     nfree(p);
 ac>     return 0;
 ac> }

 ac> Here foo() can only set its local copy of p to NULL. It can't modify
 ac> the original pointer.

 ac> There's not really any way around this kind of mistake in C, other
 ac> than to run it through a debugger, examine the code and fix it by
 ac> hand.

We'll wait for Paul to test it.

Michael

... node (at) f1042 (dot) ru
--- GoldED+/LNX 1.1.5-b20180707
* Origin: Moscow, Russia (2:5020/1042)

SOURCE: echomail via QWK@pharcyde.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.