From b182aa2cfab793e566c92183c361e78f4d6f84cb Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Wed, 3 Sep 2014 17:13:22 +0200 Subject: erts: Fix bug with enif_make_copy reallocating writable binary that could invalidate a pointer received from an earlier call to enif_inspect_binary. Solution: Emasculate writable binary at enif_inspect_binary. There are room for optimizations here as we now do an unconditional emasculation even though enif_make_copy is not called later in the NIF. --- system/doc/efficiency_guide/binaryhandling.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'system/doc') diff --git a/system/doc/efficiency_guide/binaryhandling.xml b/system/doc/efficiency_guide/binaryhandling.xml index 6b0df49011..4ba1378059 100644 --- a/system/doc/efficiency_guide/binaryhandling.xml +++ b/system/doc/efficiency_guide/binaryhandling.xml @@ -5,7 +5,7 @@
2007 - 2013 + 2014 Ericsson AB, All Rights Reserved @@ -237,8 +237,9 @@ Bin = <> %% Bin1 will be COPIED

Bin1 will be copied in the third line.

The same thing happens if you insert a binary into an ets - table or send it to a port using erlang:port_command/2.

- + table or send it to a port using erlang:port_command/2 or pass it to + enif_inspect_binary + in a NIF.

Matching a binary will also cause it to shrink and the next append operation will copy the binary data:

-- cgit v1.2.3