Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fix of the package clucene #10858

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions SPECS-EXTENDED/clucene/0001-Fix-missing-include-time.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From c1c2000c35ff39b09cb70fbdf66a107d3b17a674 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Wed, 12 Oct 2022 08:40:49 +0200
Subject: [PATCH] Fix missing #include <time.h>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

At least on recent Fedora 37 beta, building now failed with

> CLucene/document/DateTools.cpp:26:19: error: ‘gmtime’ was not declared in this scope
> 26 | tm *ptm = gmtime(&secs);
> | ^~~~~~

etc.

As it turns out, after 22f9d40320e3deeaa8d6aaa7a770077c20a21dae "git-svn-id:
https://clucene.svn.sourceforge.net/svnroot/clucene/branches/lucene2_3_2@2672
20ef185c-fe11-0410-a618-ba9304b01011" on 2008-06-26 had commented out
_CL_TIME_WITH_SYS_TIME in clucene-config.h.cmake as "not actually used for
anything", then cceccfb52917b5f4da447f1cf20c135952d41442 "Presenting DateTools
and deprecating DateField. DateTools still requires some testing and its own
unit testing" on 2008-06-29 had introduced this use of it (into then
src/CLucene/document/DateTools.H). And apparently most build environments have
silently been happy ever since when the dead leading check for
_CL_TIME_WITH_SYS_TIME didn't include both <sys/time.h> and <time.h>, but the
following check for _CL_HAVE_SYS_TIME_H only included <sys/time.h> but not
<time.h>.
---
src/shared/CLucene/clucene-config.h.cmake | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/shared/CLucene/clucene-config.h.cmake b/src/shared/CLucene/clucene-config.h.cmake
index bd8683a5..6fe0f92b 100644
--- a/src/shared/CLucene/clucene-config.h.cmake
+++ b/src/shared/CLucene/clucene-config.h.cmake
@@ -100,8 +100,7 @@ ${SYMBOL__T}
//#cmakedefine _CL_STAT_MACROS_BROKEN

/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-//not actually used for anything...
-//#cmakedefine _CL_TIME_WITH_SYS_TIME 1
+#cmakedefine _CL_TIME_WITH_SYS_TIME 1

/* Define that we will be using -fvisibility=hidden, and
* make public classes visible using __attribute__ ((visibility("default")))
--
2.37.3

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From 44cc1d696b6528712d92d33660dd8017dcd0b3e2 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Wed, 31 Jul 2019 16:57:31 +0200
Subject: [PATCH 1/2] Make sure to return value from non-void function

This had been commented out with 92145f058c88a9607341d8a20c3944a96ec00cf8
"All remaining memory leaks int tests removed. Fixes made by Veit and Anthony
Novatsis are incorporated" for no apparent reason---presumably by accident.

The effect (besides a -Wreturn-type warning) when building e.g. RelWithDebInfo
(i.e., with optimizations) on Fedora 30 (with GCC 9.1) was that the implicit
call to ~WhitespaceAnalyzer at the end of searchDocs was directly followed
(lacking the code sequence corresponding to "return 0;") by some compiler-
generated code to jump into some _Z10searchDocsPv.cold code (which is apparently
meant as an optimization, to be called from certain cold conditions) which
happened to also call ~WhitespaceAnalyzer. The net effect was that the

WhitespaceAnalyzer an;

object was deleted twice, causing a SIGSEGV.
---
src/test/search/TestIndexSearcher.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/search/TestIndexSearcher.cpp b/src/test/search/TestIndexSearcher.cpp
index 5c410ff4..02c21aaf 100644
--- a/src/test/search/TestIndexSearcher.cpp
+++ b/src/test/search/TestIndexSearcher.cpp
@@ -28,7 +28,7 @@ _LUCENE_THREAD_FUNC(searchDocs, _searcher) {
_CLLDELETE(query);

CONDITION_WAIT(deleteMutex, deleteCondition);
-// _LUCENE_THREAD_FUNC_RETURN(0);
+ _LUCENE_THREAD_FUNC_RETURN(0);
}

void testEndThreadException(CuTest *tc) {
--
2.21.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
From bdc374bfbb0ca34ddb40713eb51d8535fdf11952 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Wed, 31 Jul 2019 16:27:33 +0200
Subject: [PATCH 2/2] Avoid deadlock in TestIndexSearcher

---
src/test/search/TestIndexSearcher.cpp | 51 +++++++++++++++++++++------
1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/src/test/search/TestIndexSearcher.cpp b/src/test/search/TestIndexSearcher.cpp
index 02c21aaf..a6dde5ba 100644
--- a/src/test/search/TestIndexSearcher.cpp
+++ b/src/test/search/TestIndexSearcher.cpp
@@ -8,9 +8,11 @@

DEFINE_MUTEX(searchMutex);
DEFINE_CONDITION(searchCondition);
+bool searchReady;

DEFINE_MUTEX(deleteMutex);
DEFINE_CONDITION(deleteCondition);
+bool deleteReady;

_LUCENE_THREAD_FUNC(searchDocs, _searcher) {

@@ -19,15 +21,20 @@ _LUCENE_THREAD_FUNC(searchDocs, _searcher) {
Query * query = QueryParser::parse(_T("one"), _T("content"), &an);
Hits * hits = searcher->search(query);

-// _LUCENE_SLEEP(9999); //make sure that searchMutex is being waited on...
+ {
+ SCOPED_LOCK_MUTEX(searchMutex);
+ searchReady = true;
+ CONDITION_NOTIFYALL(searchCondition);
+ }

- CONDITION_NOTIFYALL(searchCondition);
SCOPED_LOCK_MUTEX(deleteMutex);

_CLLDELETE(hits);
_CLLDELETE(query);

- CONDITION_WAIT(deleteMutex, deleteCondition);
+ while (!deleteReady) {
+ CONDITION_WAIT(deleteMutex, deleteCondition);
+ }
_LUCENE_THREAD_FUNC_RETURN(0);
}

@@ -55,13 +62,24 @@ void testEndThreadException(CuTest *tc) {

// this sequence is OK: delete searcher after search thread finish
{
+ searchReady = false;
+ deleteReady = false;
+
IndexSearcher * searcher = _CLNEW IndexSearcher(&ram);
_LUCENE_THREADID_TYPE thread = _LUCENE_THREAD_CREATE(&searchDocs, searcher);
- SCOPED_LOCK_MUTEX(searchMutex);

- CONDITION_WAIT(searchMutex, searchCondition);
-// _LUCENE_SLEEP(9999); //make sure that deleteMutex is being waited on...
- CONDITION_NOTIFYALL(deleteCondition);
+ {
+ SCOPED_LOCK_MUTEX(searchMutex);
+ while (!searchReady) {
+ CONDITION_WAIT(searchMutex, searchCondition);
+ }
+ }
+
+ {
+ SCOPED_LOCK_MUTEX(deleteMutex);
+ deleteReady = true;
+ CONDITION_NOTIFYALL(deleteCondition);
+ }

_LUCENE_THREAD_JOIN(thread);

@@ -71,14 +89,27 @@ void testEndThreadException(CuTest *tc) {

// this produces memory exception: delete searcher after search finish but before thread finish
{
+ searchReady = false;
+ deleteReady = false;
+
IndexSearcher * searcher = _CLNEW IndexSearcher(&ram);
_LUCENE_THREADID_TYPE thread = _LUCENE_THREAD_CREATE(&searchDocs, searcher);
- SCOPED_LOCK_MUTEX(searchMutex);

- CONDITION_WAIT(searchMutex, searchCondition);
+ {
+ SCOPED_LOCK_MUTEX(searchMutex);
+ while (!searchReady) {
+ CONDITION_WAIT(searchMutex, searchCondition);
+ }
+ }
+
searcher->close();
_CLLDELETE(searcher);
- CONDITION_NOTIFYALL(deleteCondition);
+
+ {
+ SCOPED_LOCK_MUTEX(deleteMutex);
+ deleteReady = true;
+ CONDITION_NOTIFYALL(deleteCondition);
+ }

_LUCENE_THREAD_JOIN(thread);
}
--
2.21.0

38 changes: 23 additions & 15 deletions SPECS-EXTENDED/clucene/clucene.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Distribution: Azure Linux
Summary: A C++ port of Lucene
Name: clucene
Version: 2.3.3.4
Release: 39%{?dist}
Release: 40%{?dist}
# From 'COPYING':
# - RSA license: src\CLucene\util\MD5Digester.cpp
# - BSD license: cmake/MacroCheckGccVisibility.cmake, MacroEnsureVersion.cmake, and src/core/util/Compress.cpp
Expand All @@ -27,6 +27,7 @@ BuildRequires: cmake
BuildRequires: gawk
BuildRequires: gcc-c++
BuildRequires: zlib-devel
BuildRequires: make

## upstreamable patches
# include LUCENE_SYS_INCLUDES in pkgconfig --cflags output
Expand All @@ -43,6 +44,13 @@ Patch51: clucene-core-2.3.3.4-install_contribs_lib.patch
Patch52: clucene-core-2.3.3.4-CLuceneConfig.patch
# Fix tests for undefined usleep
Patch53: clucene-core-2.3.3.4-usleep.patch
# Upstream at <https://sourceforge.net/p/clucene/bugs/232/> "Patches for
# TestIndexSearcher failures":
Patch54: 0001-Make-sure-to-return-value-from-non-void-function.patch
Patch55: 0002-Avoid-deadlock-in-TestIndexSearcher.patch
# Upstream at <https://sourceforge.net/p/clucene/code/merge-requests/3/> "Fix
# missing #include <time.h>":
Patch56: 0001-Fix-missing-include-time.h.patch

%description
CLucene is a C++ port of the popular Apache Lucene search engine
Expand Down Expand Up @@ -79,32 +87,29 @@ Requires: %{name}-core%{?_isa} = %{version}-%{release}

%prep
%setup -n %{name}-core-%{version}

%patch 50 -p1 -b .pkgconfig
%patch 51 -p1 -b .install_contribs_lib
%patch 52 -p1 -b .CLuceneConfig
%patch 53 -p1 -b .usleep

%patch -P50 -p1 -b .pkgconfig
%patch -P51 -p1 -b .install_contribs_lib
%patch -P52 -p1 -b .CLuceneConfig
%patch -P53 -p1 -b .usleep
%patch -P54 -p1 -b .return-value
%patch -P55 -p1 -b .avoid-deadlock
%patch -P56 -p1 -b .missing-include

# nuke bundled code
rm -rfv src/ext/{boost/,zlib/}


%build
mkdir %{_target_platform}
pushd %{_target_platform}
%{cmake} \
-DBUILD_CONTRIBS_LIB:BOOL=ON \
-DLIB_DESTINATION:PATH=%{_libdir} \
-DLUCENE_SYS_INCLUDES:PATH=%{_libdir} \
..
popd

make %{?_smp_mflags} -C %{_target_platform}
-DLUCENE_SYS_INCLUDES:PATH=%{_libdir}

%cmake_build

%install
make install/fast DESTDIR=%{buildroot} -C %{_target_platform}

%cmake_install

%check
export PKG_CONFIG_PATH=%{buildroot}%{_libdir}/pkgconfig
Expand Down Expand Up @@ -145,6 +150,9 @@ time make -C %{_target_platform} test ARGS="--timeout 300 --output-on-failure" |


%changelog
* Mon Oct 28 2024 Sumit Jena <v-sumitjena@microsoft.com> - 2.3.3.4-40
- Added essential patches for build fix.

* Thu Feb 22 2024 Pawel Winogrodzki <pawelwi@microsoft.com> - 2.3.3.4-39
- Updating naming for 3.0 version of Azure Linux.

Expand Down
Loading