[erlang-questions] ets:select bug
Sean Hinde
sean.hinde@REDACTED
Tue Sep 4 17:12:37 CEST 2007
Hi,
We came across a bug in ets:select and related functions that can
produce partial outputs.
If you specify a chunk size as a multiple of 1000 you get the whole
table, not just the chunk. Cue out of memory crash.
2 patches follow based on R9C-0. The second patch fixes our bug
introduced by the first ;-)
The fault still seems to appear in current releases.
Sean
diff -r -u otp_src_R9C-0-synapse-C7/erts/emulator/beam/erl_db_tree.c
otp_src_R9C-0/erts/emulator/beam/erl_db_tree.c
--- otp_src_R9C-0-synapse-C7/erts/emulator/beam/erl_db_tree.c
2007-05-18 16:59:53.000000000 -0700
+++ otp_src_R9C-0/erts/emulator/beam/erl_db_tree.c 2007-05-18
17:10:42.000000000 -0700
@@ -831,7 +831,7 @@
BUMP_REDS(p, 1000 - sc.max);
- if (sc.max > 0) {
+ if (sc.max > 0 || sc.got == chunk_size) {
if (chunk_size) {
Eterm *hp;
unsigned sz;
@@ -1276,7 +1276,7 @@
}
BUMP_REDS(p, 1000 - sc.max);
- if (sc.max > 0) {
+ if (sc.max > 0 || sc.got == chunk_size) {
Eterm *hp;
unsigned sz;
diff -u -r otp_src_R9C-0/erts/emulator/beam/erl_db_tree.c
otp_src_R9C-0-new/erts/emulator/beam/erl_db_tree.c
--- otp_src_R9C-0/erts/emulator/beam/erl_db_tree.c 2007-06-29
13:11:42.000000000 -0700
+++ otp_src_R9C-0-new/erts/emulator/beam/erl_db_tree.c 2007-06-29
12:57:25.000000000 -0700
@@ -831,7 +831,7 @@
BUMP_REDS(p, 1000 - sc.max);
- if (sc.max > 0 || sc.got == chunk_size) {
+ if (sc.max > 0 || (chunk_size && sc.got == chunk_size)) {
if (chunk_size) {
Eterm *hp;
unsigned sz;
More information about the erlang-questions
mailing list