Comments (1)
Just got hit by this bug too, when storing & analyzing field with value “As multiple of 𝜋” — that last character is U+1D70B MATHEMATICAL ITALIC SMALL PI. The noteworthy thing about that last character — which is the cause of the crash — is that it cannot be represented in UCS-2, it is outside of BMP and can only be represented with surrogate pairs in UTF-16.
The place the code crashes on is on this line in StandardTokenizerImpl::getNextToken()
:
int32_t zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]];
The value of zzInput
at the time of crash is 120587 == 0x1D70B
and it crashes, predictably enough, because the ZZ_CMAP()
array is 65536 entries long.
I think it’s clear enough how this bug happened: the code is converted from Java original. Java uses UTF-16 for its strings and this situation can never happen in it. Likewise, it cannot happen on Windows, where sizeof(wchar_t) == 2
. On Unix and OS X, though, wchar_t
is 32bit and wstring
is UTF-32/UCS-4 and what would only be representable with surrogate pairs in Java is a single wchar_t
value and crashing ensues.
As to how to fix this, I unfortunately don’t have a clue. The safest would be to simply use basic_string<char16_t>
all over the place (breaking compatibility with existing code), or to use it in just this method — that would make Lucene++ closer to the Java original (I’m not familiar with Lucene++ enough to understand what else may break by using non-UTF-16 inputs).
Probably better would be to just patch up this method and perhaps use a fixed “character class" value for anything over 0xFFFF (the analysis won’t be particularly good then — but hey, so what). The trouble is that all this is completely undocumented as far as I can tell and I don’t know what the values in _ZZ_CMAP
even mean.
Playing with it in a debugger, it seems that the value of zzCMapL[some_english_character]
is 10. Perhaps it would be acceptable, at least as an interim solution, to just use that for all non-BMP characters? After all, Lucene 3.0’s StandardTokenizer is explicitly for European languages… (So I guess porting 3.1’s Unicode tokenizer would be another solution.)
I’m more than willing to work on fixing it (for Poedit, handling Unicode data is kind of important), but I could really use some pointers in the right direction(s)...
from luceneplusplus.
Related Issues (20)
- search in lucene++, most CPU resources are occupied by synclock HOT 2
- Ubuntu 18.04 doesn't work cmake HOT 6
- Facets search HOT 2
- Any example?
- Will the API remain compatible with the java version? HOT 1
- performance optimization HOT 6
- Uninitialized AttributeFactory instance HOT 22
- Tests failing on macOS HOT 6
- Multiple thread sanitizer hits when running the tests
- Errors When Compiling on Ubuntu 22.04 HOT 8
- more cmake options to configure and build LucenePlusPlus
- lucene posting list implementation
- filter cardinality estimation
- is multithreading supported?
- boost::iostreams:: error in compressionTools.cpp, Boost version-1.81 HOT 1
- search demo crash on windows
- Linking error due to boost::filesystem::detail::copy_file
- Can't compile own Analyzer with MSVC with wrong order of includes
- Build with tests fails on macOS 12–14: `gtest-internal.h: error: use of undeclared identifier 'FLT_MAX'`
- Add list of changes between versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luceneplusplus.