xiaoxiang781216 commented on code in PR #18883:
URL: https://github.com/apache/nuttx/pull/18883#discussion_r3252752387
##########
arch/sim/src/sim/posix/sim_macho_init.c:
##########
@@ -96,23 +99,28 @@ static void save_and_replace_init_funcs(int argc, const
char *argv[],
g_saved_envp = envp;
g_saved_apple = apple;
- g_saved_init_funcs = malloc(g_num_saved_init_funcs *
- sizeof(*g_saved_init_funcs));
+ g_saved_init_funcs = malloc((nfuncs - 1) * sizeof(*g_saved_init_funcs));
allow_write(&mod_init_func_start, &mod_init_func_end);
- int i = 0;
+ i = 0;
for (fp = &mod_init_func_start; fp < &mod_init_func_end; fp++)
{
if (*fp == save_and_replace_init_funcs)
{
- assert(i == 0);
Review Comment:
please study the code to understand how the thing work: you must find a
method to ensure save_and_replace_init_funcs come to first, otherwise all
constructors before save_and_replace_init_funcs get executed too early. That's
why the origin author add assert in the code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]