[erlang-patches] [PATCH] Fix format specifiers in erl_exit messages

Niclas Axelsson burbas@REDACTED
Mon Feb 28 15:55:13 CET 2011


On 02/26/2011 12:00 AM, Michael Santos wrote:
> Fix an error message caused by using signed integer specifiers as seen
> in a tweet by @metabrew:
>
>      #erlang VM crashed with "no next heap size found: -2090496108,
>      offset 0", suddenly allocated all available RAM
>
> Also correct mis-typed string formats in bif.c.
> ---
>   erts/emulator/beam/bif.c    |    4 ++--
>   erts/emulator/beam/erl_gc.c |    2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
> index bb237e3..9e88ac9 100644
> --- a/erts/emulator/beam/bif.c
> +++ b/erts/emulator/beam/bif.c
> @@ -3352,7 +3352,7 @@ BIF_RETTYPE erts_debug_display_1(BIF_ALIST_1)
>       erts_dsprintf_buf_t *dsbufp = erts_create_tmp_dsbuf(64);
>       pres = erts_dsprintf(dsbufp, "%.*T\n", INT_MAX, BIF_ARG_1);
>       if (pres<  0)
> -	erl_exit(1, "Failed to convert term to string: %d (s)\n",
> +	erl_exit(1, "Failed to convert term to string: %d (%s)\n",
>   		 -pres, erl_errno_id(-pres));
>       hp = HAlloc(BIF_P, 2*dsbufp->str_len); /* we need length * 2 heap words */
>       res = buf_to_intlist(&hp, dsbufp->str, dsbufp->str_len, NIL);
> @@ -3470,7 +3470,7 @@ term2list_dsprintf(Process *p, Eterm term)
>       erts_dsprintf_buf_t *dsbufp = erts_create_tmp_dsbuf(64);
>       pres = erts_dsprintf(dsbufp, "%T", term);
>       if (pres<  0)
> -	erl_exit(1, "Failed to convert term to list: %d (s)\n",
> +	erl_exit(1, "Failed to convert term to list: %d (%s)\n",
>   		 -pres, erl_errno_id(-pres));
>       hp = HAlloc(p, 2*dsbufp->str_len); /* we need length * 2 heap words */
>       res = buf_to_intlist(&hp, dsbufp->str, dsbufp->str_len, NIL);
> diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c
> index 2aa932e..91eb420 100644
> --- a/erts/emulator/beam/erl_gc.c
> +++ b/erts/emulator/beam/erl_gc.c
> @@ -214,7 +214,7 @@ erts_next_heap_size(Uint size, Uint offset)
>   		low = mid + 1;
>   	    }
>   	}
> -	erl_exit(1, "no next heap size found: %d, offset %d\n", size, offset);
> +	erl_exit(1, "no next heap size found: %u, offset %u\n", size, offset);
>       }
>       return 0;
>   }
>    
Thanks Michael,

Your branch have been merged to 'pu'.

Regards,
Niclas Axelsson, Erlang/OTP


More information about the erlang-patches mailing list