Comments (8)
(gdb) print id
$2 = 65524
(gdb) print d
$3 = (Disjunct *) 0x7ffdce75d660
(gdb) print d->match_id
$4 = 65512
from link-grammar.
Hmm. match_id
is a uint16_t
and the value here is darned close to the overflow value...
from link-grammar.
Hmm. match_id is a uint16_t and the value here is darned close to the overflow value...
I think (not validated by actual debugging but only by code inspection) that this causes the bug.
The purpose of the match_id
check is to validate that there are no extra or missing pops up in the match_list
stack, and also that no memory corruption occurs in it. To that end, in form_match_list()
the id
value is grabbed into a local variable lid
, so the same value is used for all the match_list
entries in the same form_match_list()
, not caring whether id
has been changed meanwhile by another thread.
But note line 84:
link-grammar/link-grammar/parse/fast-match.c
Lines 74 to 87 in fe7886a
When
id
wrapped around back to 0, then no assignment is done and the previous value of d->match_id
persists for all the match_list
entries in this form_match_list()
invocation (the persisting values are those that existed just near the wrapping around, and thus are close to 65535).
I think the fix is just to remove lines 83-85 (which exist may be due to a code rot).
On the same occasion, it is possible to save a 0 assignment in count.c
. However, the code there seems to be a moving target while I'm writing this...
from link-grammar.
What about this:
link-grammar/link-grammar/parse/fast-match.c
Lines 609 to 616 in fe7886a
That looks like a non-atomic increment to me; two threads can ++id
at the same time. I believe I have 10 threads running LG at the same time.
from link-grammar.
I just now pushed this: 9f73b37 in the hope that it will narrow down or avoid the problem.
from link-grammar.
I'm confused by this statement:
I think the fix is just to remove lines 83-85 (which exist may be due to a code rot).
If those are removed, then the id does not need to be passed as an argument to any of the functions, and the id is then not set anywhere, so it will always be zero. Did you mean something else?
from link-grammar.
I'm confused by this statement:
You are right!
Only the (id != 0)
should be removed. The d->match_d = id
assignment should be retained.
The #ifdef/#endif should also be retained for future efficiency if VERIFY_MATCH_LIST
will not be used.
So it should be:
#ifdef VERIFY_MATCH_LIST
id->match_id = id;
#endif
That looks like a non-atomic increment to me; two threads can
++id
at the same time. I believe I have 10 threads running LG at the same time.
No problem with that, since int lid = ++id
grabs a local value that is kept constant for the whole same invocation of form_match_list()
. The value of the global id
can continue to change, but the form_match_list()
code doesn't look at it anymore in the same invocation and all the match_list
elements in this invocation only use the fixed (per invocation) local copy.
from link-grammar.
Closing. Ran for two days in half-a-dozen threads, no issues arose.
from link-grammar.
Related Issues (20)
- insane ./configure in github circleci HOT 3
- incorrect use of pcre2_match_data would result in severe memory leak HOT 15
- Emscripten build fails HOT 3
- multi-threaded dictionary crash HOT 18
- Problems in printing sentence split time HOT 2
- pool management idea... HOT 1
- Link-deduplication multi-connector issue
- Sharing parse choice elements HOT 8
- pool_alloc_vec() with too many elts.
- classic_parse: Sentence disjunct count 108279 exceeded limit 105123 HOT 6
- Stop litering `.lg_history` in current directory. HOT 8
- Get rid of `null_count>0` parsing HOT 26
- Flood-counting HOT 35
- SAT parser improvements HOT 4
- Get rid of max-cost HOT 14
- Open work items for 5.12.5 HOT 12
- Word "test" in English dict 5.12.1 vs older ones HOT 3
- `www.abisource.com` is not accessible HOT 16
- Make - failure to find link-names.o HOT 3
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 link-grammar.