In the last episode (May 21), Vikash Badal said:
> Excuse me if this is a stupid questions.
>
> I have a thread socket application that seems to be behaving strangely
>
> In a worker thread, I have the following.
>
> <CODE>-----------
> LogMessage(DEBUG_0, "allocated %ld", malloc_usable_size(inst));
>
> free(inst);
>
> LogMessage(DEBUG_0, "after free allocated %ld", malloc_usable_size(inst));
>
> return 0;
> -----------</CODE>
>
> output> allocated 2304
> output> after free allocated 2304
>
> from playing around, this should have segfaulted but it didn't
You're invoking undefined behaviour here by calling malloc_usable_size on a
free'd pointer. The function is free to crash, return useful data, or
return useless data, at its discretion :)
As long as you only call it on pointers that are still valid you will be
okay.
--
Dan Nelson
[email protected]
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[email protected]"