R12B01 erl_misc_utils.c stack-trashing bug, + a patch

Michael Turner leap@REDACTED
Wed Jul 29 10:34:46 CEST 2009


Was trying to build on a i386_unknown_freebsd4.10, with a gcc about 10
years old.  The build died in /lib/parsetools/src.  gdb revealed
revealed a trashed stack.

The source of the problem became clear after narrowing it down to a
function in erl_misc_utils.c.  There are assignments to mib[0] and
mib[1], with mib declared size zero. (Yes.  sizeof (mib) == 0.  The
first time I've ever seen that.  And the last, I hope.)

Dimension of 2 for mib[] seemed appropriate in context.  The build
continued after that fix.

==========

--- otp_src_R13B01/erts/lib_src/common/erl_misc_utils.c.~1~	Wed Jul 29
00:53:30 2009
+++ otp_src_R13B01/erts/lib_src/common/erl_misc_utils.c	Tue Jul 28
22:17:45 2009
@@ -172,7 +172,7 @@ erts_cpu_info_update(erts_cpu_info_t *cp
 #elif defined(HAVE_SYS_SYSCTL_H) && defined(CTL_HW) && (defined(HW_NCPU)
\
 							|| defined(HW_AVAILCPU))
     {
-	int mib[0];
+	int mib[2];
 	size_t len;

#ifdef HW_NCPU



More information about the erlang-bugs mailing list