[1/2] lucy git commit: Fix refcount order when overwriting.

2016-03-03 Thread marvin
Repository: lucy
Updated Branches:
  refs/heads/master fb986db61 -> a738254b6


Fix refcount order when overwriting.

When there's a possibility that a recounted value is overwriting itself,
delay the decref until after any incref so that there is no way the
refcount can fall to 0 prior to the incref.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/71c99cf6
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/71c99cf6
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/71c99cf6

Branch: refs/heads/master
Commit: 71c99cf69008b7742ffa41218574c308d9494e5f
Parents: 2439888
Author: Marvin Humphrey 
Authored: Wed Mar 2 19:32:06 2016 -0800
Committer: Marvin Humphrey 
Committed: Wed Mar 2 19:32:06 2016 -0800

--
 core/Lucy/Highlight/Highlighter.c | 6 --
 core/Lucy/Index/IndexManager.c| 3 ++-
 core/Lucy/Index/PolyLexicon.c | 3 ++-
 core/Lucy/Index/SegWriter.c   | 3 ++-
 core/Lucy/Index/Snapshot.c| 3 ++-
 core/Lucy/Index/TermStepper.c | 3 ++-
 core/Lucy/Search/Collector.c  | 6 --
 core/Lucy/Search/MatchDoc.c   | 3 ++-
 core/Lucy/Search/PolyQuery.c  | 3 ++-
 core/Lucy/Search/QueryParser/ParserElem.c | 6 +++---
 core/Lucy/Search/TopDocs.c| 3 ++-
 core/Lucy/Store/FileHandle.c  | 3 ++-
 core/Lucy/Store/Folder.c  | 3 ++-
 core/Lucy/Store/InStream.c| 3 ++-
 14 files changed, 33 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/lucy/blob/71c99cf6/core/Lucy/Highlight/Highlighter.c
--
diff --git a/core/Lucy/Highlight/Highlighter.c 
b/core/Lucy/Highlight/Highlighter.c
index f25888f..6963823 100644
--- a/core/Lucy/Highlight/Highlighter.c
+++ b/core/Lucy/Highlight/Highlighter.c
@@ -103,15 +103,17 @@ Highlighter_Highlight_IMP(Highlighter *self, String 
*text) {
 void
 Highlighter_Set_Pre_Tag_IMP(Highlighter *self, String *pre_tag) {
 HighlighterIVARS *const ivars = Highlighter_IVARS(self);
-DECREF(ivars->pre_tag);
+String *temp = ivars->pre_tag;
 ivars->pre_tag = Str_Clone(pre_tag);
+DECREF(temp);
 }
 
 void
 Highlighter_Set_Post_Tag_IMP(Highlighter *self, String *post_tag) {
 HighlighterIVARS *const ivars = Highlighter_IVARS(self);
-DECREF(ivars->post_tag);
+String *temp = ivars->post_tag;
 ivars->post_tag = Str_Clone(post_tag);
+DECREF(temp);
 }
 
 String*

http://git-wip-us.apache.org/repos/asf/lucy/blob/71c99cf6/core/Lucy/Index/IndexManager.c
--
diff --git a/core/Lucy/Index/IndexManager.c b/core/Lucy/Index/IndexManager.c
index 9d59e77..7823499 100644
--- a/core/Lucy/Index/IndexManager.c
+++ b/core/Lucy/Index/IndexManager.c
@@ -325,8 +325,9 @@ IxManager_Make_Snapshot_Read_Lock_IMP(IndexManager *self,
 void
 IxManager_Set_Folder_IMP(IndexManager *self, Folder *folder) {
 IndexManagerIVARS *const ivars = IxManager_IVARS(self);
-DECREF(ivars->folder);
+Folder *temp = ivars->folder;
 ivars->folder = (Folder*)INCREF(folder);
+DECREF(temp);
 }
 
 Folder*

http://git-wip-us.apache.org/repos/asf/lucy/blob/71c99cf6/core/Lucy/Index/PolyLexicon.c
--
diff --git a/core/Lucy/Index/PolyLexicon.c b/core/Lucy/Index/PolyLexicon.c
index f0fb288..61e1976 100644
--- a/core/Lucy/Index/PolyLexicon.c
+++ b/core/Lucy/Index/PolyLexicon.c
@@ -134,8 +134,9 @@ PolyLex_Next_IMP(PolyLexicon *self) {
 || Obj_Compare_To(ivars->term, candidate) != 0
) {
 // Succeed if the next item in the queue has a different term.
-DECREF(ivars->term);
+Obj *temp = ivars->term;
 ivars->term = Obj_Clone(candidate);
+DECREF(temp);
 return true;
 }
 else {

http://git-wip-us.apache.org/repos/asf/lucy/blob/71c99cf6/core/Lucy/Index/SegWriter.c
--
diff --git a/core/Lucy/Index/SegWriter.c b/core/Lucy/Index/SegWriter.c
index fa6a552..67c87e4 100644
--- a/core/Lucy/Index/SegWriter.c
+++ b/core/Lucy/Index/SegWriter.c
@@ -222,8 +222,9 @@ SegWriter_Add_Data_Writer_IMP(SegWriter *self, DataWriter 
*writer) {
 void
 SegWriter_Set_Del_Writer_IMP(SegWriter *self, DeletionsWriter *del_writer) {
 SegWriterIVARS *const ivars = SegWriter_IVARS(self);
-DECREF(ivars->del_writer);
+DeletionsWriter *temp = ivars->del_writer;
 ivars->del_writer = (DeletionsWriter*)INCREF(del_writer);
+DECREF(temp);
 }
 
 DeletionsWriter*


[2/2] lucy git commit: Merge branch 'LUCY-292-decref-order'

2016-03-03 Thread marvin
Merge branch 'LUCY-292-decref-order'

This closes #34.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/a738254b
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/a738254b
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/a738254b

Branch: refs/heads/master
Commit: a738254b66fa2d49729725affbdf2c93e0bef84a
Parents: fb986db 71c99cf
Author: Marvin Humphrey 
Authored: Thu Mar 3 10:46:00 2016 -0800
Committer: Marvin Humphrey 
Committed: Thu Mar 3 10:46:42 2016 -0800

--
 core/Lucy/Highlight/Highlighter.c | 6 --
 core/Lucy/Index/IndexManager.c| 3 ++-
 core/Lucy/Index/PolyLexicon.c | 3 ++-
 core/Lucy/Index/SegWriter.c   | 3 ++-
 core/Lucy/Index/Snapshot.c| 3 ++-
 core/Lucy/Index/TermStepper.c | 3 ++-
 core/Lucy/Search/Collector.c  | 6 --
 core/Lucy/Search/MatchDoc.c   | 3 ++-
 core/Lucy/Search/PolyQuery.c  | 3 ++-
 core/Lucy/Search/QueryParser/ParserElem.c | 6 +++---
 core/Lucy/Search/TopDocs.c| 3 ++-
 core/Lucy/Store/FileHandle.c  | 3 ++-
 core/Lucy/Store/Folder.c  | 3 ++-
 core/Lucy/Store/InStream.c| 3 ++-
 14 files changed, 33 insertions(+), 18 deletions(-)
--




lucy git commit: Guard against ord buffer overflow in SortFieldWriter

2016-03-03 Thread nwellnhof
Repository: lucy
Updated Branches:
  refs/heads/master a7a652f37 -> fb986db61


Guard against ord buffer overflow in SortFieldWriter


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/fb986db6
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/fb986db6
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/fb986db6

Branch: refs/heads/master
Commit: fb986db61293e06db54fe15054f59e7a948add0c
Parents: a7a652f
Author: Nick Wellnhofer 
Authored: Thu Mar 3 15:38:24 2016 +0100
Committer: Nick Wellnhofer 
Committed: Thu Mar 3 15:38:24 2016 +0100

--
 core/Lucy/Index/SortFieldWriter.c | 8 
 1 file changed, 8 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/lucy/blob/fb986db6/core/Lucy/Index/SortFieldWriter.c
--
diff --git a/core/Lucy/Index/SortFieldWriter.c 
b/core/Lucy/Index/SortFieldWriter.c
index f73698c..f761014 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -550,6 +550,10 @@ S_write_files(SortFieldWriter *self, OutStream *ord_out, 
OutStream *ix_out,
 // doc id 0.
 SFWriterElem *elem = (SFWriterElem*)SortFieldWriter_Fetch(self);
 SFWriterElemIVARS *elem_ivars = SFWriterElem_IVARS(elem);
+if (elem_ivars->doc_id > doc_max) {
+THROW(ERR, "doc_id %i32 greater than doc_max %i32",
+  elem_ivars->doc_id, doc_max);
+}
 ords[elem_ivars->doc_id] = ord;
 ords[0] = 0;
 
@@ -571,6 +575,10 @@ S_write_files(SortFieldWriter *self, OutStream *ord_out, 
OutStream *ix_out,
 DECREF(last_val);
 last_val = INCREF(elem_ivars->value);
 }
+if (elem_ivars->doc_id > doc_max) {
+THROW(ERR, "doc_id %i32 greater than doc_max %i32",
+  elem_ivars->doc_id, doc_max);
+}
 ords[elem_ivars->doc_id] = ord;
 DECREF(elem);
 }



[2/2] lucy git commit: Build Go bindings with -lm

2016-03-03 Thread nwellnhof
Build Go bindings with -lm

Needed on Linux, should be harmless on Darwin.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/a7a652f3
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/a7a652f3
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/a7a652f3

Branch: refs/heads/master
Commit: a7a652f37b5fa7bd9ff66cd0ee6786a91720232d
Parents: f0500e3
Author: Nick Wellnhofer 
Authored: Thu Mar 3 14:54:20 2016 +0100
Committer: Nick Wellnhofer 
Committed: Thu Mar 3 14:54:20 2016 +0100

--
 go/build.go | 1 +
 1 file changed, 1 insertion(+)
--


http://git-wip-us.apache.org/repos/asf/lucy/blob/a7a652f3/go/build.go
--
diff --git a/go/build.go b/go/build.go
index ad951f8..8353d66 100644
--- a/go/build.go
+++ b/go/build.go
@@ -537,6 +537,7 @@ func writeConfigGO() {
"// #cgo LDFLAGS: -L%s\n"+
"// #cgo LDFLAGS: -llucy\n"+
"// #cgo LDFLAGS: -lclownfish\n"+
+   "// #cgo LDFLAGS: -lm\n"+
"import \"C\"\n",
buildDir, buildDir, buildDir, buildDir, installedLibDir, 
cfLibDir)
ioutil.WriteFile(configGO, []byte(content), 0666)



[1/2] lucy git commit: Fix Go bindings after Blob ctor changes

2016-03-03 Thread nwellnhof
Repository: lucy
Updated Branches:
  refs/heads/master 243988811 -> a7a652f37


Fix Go bindings after Blob ctor changes


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/f0500e35
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/f0500e35
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/f0500e35

Branch: refs/heads/master
Commit: f0500e351b9a1d19c6b10265af348e20bd288669
Parents: 2439888
Author: Nick Wellnhofer 
Authored: Thu Mar 3 14:36:26 2016 +0100
Committer: Nick Wellnhofer 
Committed: Thu Mar 3 14:36:26 2016 +0100

--
 go/lucy/search.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/lucy/blob/f0500e35/go/lucy/search.go
--
diff --git a/go/lucy/search.go b/go/lucy/search.go
index f2fa54a..d0a1dbe 100644
--- a/go/lucy/search.go
+++ b/go/lucy/search.go
@@ -408,7 +408,7 @@ func newMockMatcher(docIDs []int32, scores []float32) 
MockMatcher {
for i := 0; i < len(scores); i++ {
C.float32_set(floats, C.size_t(i), C.float(scores[i]))
}
-   blob = 
C.cfish_Blob_new_steal((*C.char)(unsafe.Pointer(floats)), C.size_t(size))
+   blob = C.cfish_Blob_new_steal(unsafe.Pointer(floats), 
C.size_t(size))
defer C.cfish_decref(unsafe.Pointer(blob))
}
matcher := C.lucy_MockMatcher_new(docIDsCF, blob)