Bug 1113457

Summary: abiword FTBFS against current link-grammar (blocks multiple live composes)
Product: [Fedora] Fedora Reporter: Ali Akcaagac <aliakc>
Component: abiwordAssignee: Marc Maurer <uwog>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: awilliam, jones.peter.busi, linasvepstas, uwog
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-03 16:04:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1043122    

Description Ali Akcaagac 2014-06-26 08:40:50 UTC
Error: Package: 1:libabiword-3.0.0-9.fc21.i686 (fedora)
           Requires: liblink-grammar.so.4
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Please fix if possible.

Comment 1 Adam Williamson 2014-06-27 17:08:05 UTC
*** Bug 1113645 has been marked as a duplicate of this bug. ***

Comment 2 Adam Williamson 2014-06-27 17:11:49 UTC
It failed to rebuild against the new link-grammar when someone tried:

http://koji.fedoraproject.org/koji/taskinfo?taskID=7072898

LinkGrammarWrap.cpp: In member function 'bool LinkGrammarWrap::parseSentence(PieceOfText*)':
LinkGrammarWrap.cpp:148:70: error: 'sentence_get_nth_word' was not declared in this scope
    pWordMap->m_iErrHigh = iLow + strlen(sentence_get_nth_word(sent, i));
                                                                      ^
LinkGrammarWrap.cpp:152:49: error: 'sentence_nth_word_has_disjunction' was not declared in this scope
    if(!sentence_nth_word_has_disjunction(sent, i))
                                                 ^
LinkGrammarWrap.cpp:232:20: warning: 'int linkage_get_num_sublinkages(Linkage)' is deprecated (declared at /usr/include/link-grammar/link-includes.h:461) [-Wdeprecated-declarations]
  UT_sint32 count = linkage_get_num_sublinkages(linkage);
                    ^
LinkGrammarWrap.cpp:232:55: warning: 'int linkage_get_num_sublinkages(Linkage)' is deprecated (declared at /usr/include/link-grammar/link-includes.h:461) [-Wdeprecated-declarations]
  UT_sint32 count = linkage_get_num_sublinkages(linkage);
                                                       ^
LinkGrammarWrap.cpp:238:20: warning: 'int linkage_set_current_sublinkage(Linkage, int)' is deprecated (declared at /usr/include/link-grammar/link-includes.h:465) [-Wdeprecated-declarations]
    UT_sint32 iok = linkage_set_current_sublinkage(linkage, i);
                    ^
LinkGrammarWrap.cpp:238:61: warning: 'int linkage_set_current_sublinkage(Linkage, int)' is deprecated (declared at /usr/include/link-grammar/link-includes.h:465) [-Wdeprecated-declarations]
    UT_sint32 iok = linkage_set_current_sublinkage(linkage, i);
                                                             ^
Makefile:575: recipe for target 'LinkGrammarWrap.lo' failed

upstream abiword seems pretty dead, but we should probably report the bug there. This blocks compose of Xfce, LXDE, SoaS and Games live images, so proposing as a freeze exception issue for F21 Alpha.

Comment 3 Adam Williamson 2014-06-27 17:29:54 UTC
link-grammar is kept in SVN, its API documentation is kind of a joke, and so far as I can tell, there is absolutely no 4.x to 5.x migration guide of any kind. This makes me a sad panda.

It seems sentence_get_nth_word() and sentence_nth_word_has_disjunction() disappeared between 4.x and 5.x, but the link-grammar folks really don't seem to want to make it easy for anyone to know why or how they should update their code...

Comment 4 Adam Williamson 2014-06-27 20:21:17 UTC
looks like Jon's patch from https://bugzilla.redhat.com/show_bug.cgi?id=1106100#c7 is good here.

Comment 5 Linas Vepstas 2014-06-28 01:25:39 UTC
Sorry Adam,  The API calls were marked deprecated 5 years ago; the API documentation for what to do with them has long ago vanished into the dust. 

The patch reported at   https://bugzilla.redhat.com/show_bug.cgi?id=1106100#c7 is wildly incorrect and will almost surely lead to asserts, segfaults or memory corruption.  A description of what should be done is provided in comment https://bugzilla.redhat.com/show_bug.cgi?id=1106100#c18

The last version 4.8.6 from Feb 2014 (only 4 months ago!) still supports these deprecated calls.  Given that version 5.x is still changing very rapidly, and is rather unstable, I'd strongly suggest using 4.8.6 for a while.

Comment 6 Peter H. Jones 2014-06-30 12:17:52 UTC
abiword.x86_64-3.0.0-10.fc21 allows my local build to proceed.

Comment 7 Linas Vepstas 2014-06-30 13:20:34 UTC
Here's patch 1/2 that I'm sending upstream

--- abiword-3.0.0/plugins/grammar/linkgrammarwrap/LinkGrammarWrap.cpp.orig	2014-06-29 14:50:30.000000000 -0500
+++ abiword-3.0.0/plugins/grammar/linkgrammarwrap/LinkGrammarWrap.cpp	2014-06-29 14:55:39.000000000 -0500
@@ -145,12 +145,11 @@ bool LinkGrammarWrap::parseSentence(Piec
 	  }
 	  AbiGrammarError * pWordMap = new  AbiGrammarError();
 	  pWordMap->m_iErrLow = iLow;
-	  pWordMap->m_iErrHigh = iLow + strlen(sentence_get_nth_word(sent, i));
+	  pWordMap->m_iErrHigh = iLow + strlen(linkage_get_word(linkage, i));
 	  pWordMap->m_iWordNum = i;
 	  vecMapOfWords.addItem(pWordMap);
 	  bool bNew = false;
-	  if(!sentence_nth_word_has_disjunction(sent, i))
-	  {
+
 	    //UT_DEBUGMSG(("|%s| NULL LINK\n",sent->word[i].string));
 	    if(pErr == NULL)
 	    {
@@ -167,7 +166,7 @@ bool LinkGrammarWrap::parseSentence(Piec
 		}
 		pErr = new AbiGrammarError();
 	      }
-	      iHigh = iLow + strlen(sentence_get_nth_word(sent, i));
+	      iHigh = iLow + strlen(linakge_get_word(linkage, i));
 	      pErr->m_iErrLow = iLow + iOff -1;
 	      pErr->m_iErrHigh = iHigh + iOff -1;
 	      if(pErr->m_iErrLow < 0)
@@ -188,7 +187,7 @@ bool LinkGrammarWrap::parseSentence(Piec
 	      //
 	      // Expand the sqiggle
 	      //
-	      iHigh = iLow + strlen(sentence_get_nth_word(sent, i)) + iOff;
+	      iHigh = iLow + strlen(linkage_get_word(linkage, i)) + iOff;
 	      pErr->m_iErrHigh = iHigh;
 	      if(pErr->m_iErrHigh < totlen-1)
 	      {
@@ -196,8 +195,7 @@ bool LinkGrammarWrap::parseSentence(Piec
 	      }
 	      pErr->m_iWordNum = i;
 	    }
-	  }
-	  iLow += strlen(sentence_get_nth_word(sent, i));
+	  iLow += strlen(linkage_get_word(linkage, i));
 	}
 	//
 	// No NULL links but still an error , mark the whole sentence bad.

Comment 8 Linas Vepstas 2014-06-30 13:31:08 UTC
Here's patch 2/2.  Neither this nor the previous patch were compiled or tested (I don't have the facilities to do this), but as link-grammar maintainer, I can certify that that they are the correct update for the existing code.

--- abiword-3.0.0/plugins/grammar/linkgrammarwrap/LinkGrammarWrap.cpp.orig	2014-06-30 08:21:30.000000000 -0500
+++ abiword-3.0.0/plugins/grammar/linkgrammarwrap/LinkGrammarWrap.cpp	2014-06-30 08:27:01.000000000 -0500
@@ -220,6 +220,7 @@ bool LinkGrammarWrap::parseSentence(Piec
 	  pErr = NULL;
 	}
 
+#ifdef DEAD_DEBUG_CODE
 	//	  for(i=0; i< pT->m_vecGrammarErrors.getItemCount(); i++)
 	// {
 	//    pErr = pT->m_vecGrammarErrors.getNthItem(i);
@@ -227,15 +228,10 @@ bool LinkGrammarWrap::parseSentence(Piec
 	//  }
 	UT_UTF8String sErr = linkage_get_violation_name(linkage);
 	//	UT_DEBUGMSG(("Top Level error message |%s|\n",sErr.utf8_str()));
-	UT_sint32 count = linkage_get_num_sublinkages(linkage);
 	//
 	// Find linkages with violations
 	//
-	for(i=0; i<count;i++)
 	{
-	  UT_sint32 iok = linkage_set_current_sublinkage(linkage, i);
-	  if(iok == 0)
-	    continue;
 	  UT_sint32 j = 0;
 	  UT_sint32 iNum = linkage_get_num_links(linkage);
 	  for(j=0;j< iNum;j++)
@@ -252,6 +248,8 @@ bool LinkGrammarWrap::parseSentence(Piec
 	  }
 	}
 	linkage_delete(linkage);
+#endif // DEAD_DEBUG_CODE
+
 	for(i=0; i<  vecMapOfWords.getItemCount(); i++)
 	{
 	  AbiGrammarError * p = vecMapOfWords.getNthItem(i);

Comment 9 Linas Vepstas 2014-06-30 13:35:00 UTC
(In reply to Linas Vepstas from comment #8)


Arghhhhh! stupid me, above #endif brackets the wrong thing and introduces a mem leak. It should be this:

>  	  }
>  	}
> +#endif // DEAD_DEBUG_CODE
> +
>  	linkage_delete(linkage);
>  	for(i=0; i<  vecMapOfWords.getItemCount(); i++)
>  	{
>  	  AbiGrammarError * p = vecMapOfWords.getNthItem(i);

Comment 10 Adam Williamson 2014-07-03 16:04:56 UTC
We now have a completed abiword build in Rawhide, so we can close this bug. Any issues with the code can be covered separately, this bug was for the FTBFS/dependency issues.