Bug #36375 NDBAPI : Segfault when old Api scan closed before execute()
Submitted: 28 Apr 2008 13:08 Modified: 9 Jul 2008 9:07
Reporter: Frazer Clement Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: NDB API Severity:S3 (Non-critical)
Version:5.1-telco-6.2+ OS:Any
Assigned to: Frazer Clement CPU Architecture:Any

[28 Apr 2008 13:08] Frazer Clement
Description:
When an 'old Api' scan is created and then closed (or the transaction containing it is closed), a segmentation fault can occur.

How to repeat:
Running the code below in a loop appears to expose the issue after a number of iterations.

  NdbTransaction* pCon = pNdb->startTransaction();
  NdbScanOperation* pOp = pCon->getNdbScanOperation(pTab->getName());
  if (pOp == NULL) {
    ERR(pCon->getNdbError());
    return NDBT_FAILED;
  }
  
  if( pOp->readTuples(NdbOperation::LM_Read) != 0) 
  {
    ERR(pCon->getNdbError());
    return NDBT_FAILED;
  }

  if( pOp->getValue(NdbDictionary::Column::ROW_COUNT) == 0)
  {
    ERR(pCon->getNdbError());
    return NDBT_FAILED;
  }

  /* Old style interpreted code api should fail when 
   * we try to use it 
   */
  if( pOp->interpret_exit_last_row() == 0)
  {
    return NDBT_FAILED;
  }

  pOp->close();

  pCon->close();

Suggested fix:
Ensure member variables used as part of NdbScanOperation->close() are always initialised.
[28 Apr 2008 14:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/46125

ChangeSet@1.2589, 2008-04-28 15:23:30+01:00, frazer@forth.ndb.mysql.com +1 -0
  Bug #36375
  Issue when old Api scan operation is closed before it has been executed.
  Uninitialised members are used during scan close, and this can result in a SEGV.
  
  Testcase for Bug 36124 provides coverage :
  
  testScan -n Bug36124
[28 Apr 2008 16:23] Bugs System
Pushed into 5.1.23-ndb-6.4.0
[28 Apr 2008 16:25] Bugs System
Pushed into 5.1.24-ndb-6.3.13
[28 Apr 2008 16:29] Bugs System
Pushed into 5.1.24-ndb-6.2.14
[9 Jul 2008 9:07] Jon Stephens
Documented bugfix in the 5.1.23-ndb-6.2.14 and 5.1.24-ndb-6.3.13 changelogs as follows:

        Closing a scan before was executed caused the application to 
        segfault.

Closed.
[12 Dec 2008 23:27] Bugs System
Pushed into 6.0.6-alpha  (revid:sp1r-frazer@forth.ndb.mysql.com-20080428142330-12313) (version source revid:jonas@mysql.com-20080808094047-4e1yiarqa2t3opg3) (pib:5)