Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 5 Mar 2019 21:05:30 +0100
From: Markus Wichmann <>
Subject: Re: Asterisk 16 function redefines

On Tue, Mar 05, 2019 at 08:28:50PM +0100, Sebastian Kemper wrote:
> #define calloc(nmemb, size) \
> 	__ast_repl_calloc(nmemb, size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
> #define malloc(size) \
> 	__ast_repl_malloc(size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
> #define free(ptr) \
> 	__ast_free(ptr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
> Compile output example:
> /home/sk/tmp/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/include/sched.h:76:28: error: expected declaration specifiers or '...' before string constant
>  void *calloc(size_t, size_t);
>                             ^

Welcome to the wonderful world of the preprocessor. The define above is
in effect here, so the compiler never sees the valid function prototype,
the compiler sees

void *__ast_repl_calloc(size_t, size_t, "sched.h", 76, "");

And can't deal with that. Maybe they should include the replacements as
the very last thing.

Nitpick, depending on how you feel about it: The name
"__ast_repl_calloc" starts with two underscores and is therefore in the
implementation namespace. So asterisk should keep their fingers off it!
They should just define the function without the underscores; what's so
hard about that?

> Regarding ASTMM_BLOCK: redefines libc functions to cause compile errors. [...]

And they cause compile errors. Mission accomplished.

I guess the code is tripping over the prototypes in sched.h.

> To me it looks like the mere definition sets off these errors for some
> reason. Is it about the syntax? To me it looks fine. I mean it looks
> like the syntax used for function-like macro definitions mentioned in
> the gcc manual.
> Again, any help appreciated.

These macros can't deal with prototypes. That is their failing. I don't
know how to do what they want to do, but this is probably not it. I'd
suggest going with ASTMM_IGNORE for now.

> Kind regards,
> Seb


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.