Re: Erlang vm beam.smp crash

Sverker Eriksson <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <[email protected]>
Oops.
Guess no one is using port_set_data with non-immediate terms.... not 
even our tests :-[

Here is the one-liner that fixes the problem.

diff --git a/erts/emulator/beam/erl_bif_port.c 
b/erts/emulator/beam/erl_bif_port.c
index afb33c1..8a622e5 100644
--- a/erts/emulator/beam/erl_bif_port.c
+++ b/erts/emulator/beam/erl_bif_port.c
@@ -554,6 +554,7 @@ BIF_RETTYPE port_set_data_2(BIF_ALIST_2)
         hp = &pdhp->heap[0];
         pdhp->off_heap.first = NULL;
         pdhp->off_heap.overhead = 0;
+       pdhp->hsize = hsize;
         pdhp->data = copy_struct(BIF_ARG_2, hsize, &hp, &pdhp->off_heap);
         data = (erts_aint_t) pdhp;
         ASSERT((data & 0x3) == 0);


Thanks Tony, for using your bug-sniffing ability for the greater good.

/Sverker, Erlang/OTP

On 09/30/2014 02:39 PM, Tony Rogvall wrote:
> I also found this:
>
> (on unix/mac, on windows use some other program)
>> Port = open_port({spawn, "cat"}, []).
>> erlang:port_set_data(Port, {1,2,3}).
> true
>> erlang:port_get_data(Port).
> ... hmm my cpu skyrockets and the computer dies a bit :-)
> then
>
> beam.smp(41283,0xb06bb000) malloc: *** mach_vm_map(size=1799625657810944) failed (error code=3)
>                 *** error: can't allocate region
>                                                 *** set a breakpoint in malloc_error_break to debug
>                    beam.smp(41283,0xb06bb000) malloc: *** mach_vm_map(size=1799625657810944) failed (error code=3)
>                                   *** error: can't allocate region
>                                                                   *** set a breakpoint in malloc_error_break to debug
>                                      beam.smp(41283,0xb06bb000) malloc: *** mach_vm_map(size=1799625656766464) failed (error code=3)
>                                                     *** error: can't allocate region
>     *** set a breakpoint in malloc_error_break to debug
>                                                        beam.smp(41283,0xb06bb000) malloc: *** mach_vm_map(size=1799625656766464) failed (error code=3)
>                                                                       *** error: can't allocate region
>                       *** set a breakpoint in malloc_error_break to debug
>
> Crash dump was written to: erl_crash.dump
> eheap_alloc: Cannot allocate 1799625656762408 bytes of memory (of type "heap_frag").
>
> /Tony
>
>
>

_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.