Bug 35102

Summary: doImport function cause LibreOffice to crash
Product: LibreOffice Reporter: KK <holofernes>
Component: BaseAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: medium    
Version: 3.3.1 release   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
Crash report or crash signature: Regression By:

Description KK 2011-03-07 17:46:12 UTC
Discovered when switched to LibreOffice from OpenOffice 3.3 where doImport worked.

Using LibreOffice to connect to Postgresql Database with PostgreSQL SDBC driver.

Calc document have written macro which connect to Postgres, and throw data into spreadsheet.
Step by step inspection of macro showed that LibreOffice crash on line:
"oSheet.getcellbyposition(0,3+j).doImport(vAttrib)"

Suspected that the problem is caused by Java version, but it happened on all Javas I have tested:
- Sun Microsystems 1.6.0_13
- Sun Microsystems 1.6.0_20 with acceasability support
- Sun Microsystems 1.6.0_24
- Free Software Foundation 1.5.0

The best results were with - Sun Microsystems 1.6.0_20 with acceasability support.
For the moment before the LibreOffice crashed I could see that doImport pasted data into spreadsheet.
LibreOffice don't throw anything on the console, which could help to backtrace.

The doImport function is very useful one, and I guess that many users are using (or will be) using it.

Below the code which cause crash.


sub hall_insert
	Dim DatabaseContext As Object
	Dim DataSource As Object
	Dim Connection As Object
	Dim InteractionHandler as Object
	Dim Statement As Object
	Dim ResultSet As Object
	Dim oSheet as Object
	sTemp$ = "Temperatura, K"
	
	baza="baza_mocvd" 
	oSheet=thiscomponent.sheets.getbyName("Hall")

	
	oCellRange = oSheet.getCellRangeByName("A5:I50")
	oCellRange.clearContents(com.sun.star.sheet.CellFlags.VALUE)
	oCellRange.clearContents(com.sun.star.sheet.CellFlags.STRING)
	'oCellRange.clearContents(com.sun.star.sheet.CellFlags.FORMULA)
	
	DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
	DataSource = DatabaseContext.getByName(baza)
	 
	If Not DataSource.IsPasswordRequired Then
	  Connection = DataSource.GetConnection("","")
	Else
	  InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
	  Connection = DataSource.ConnectWithCompletion(InteractionHandler)
	End If
		
	If oSheet.getCellByPosition(1,0).getString() = "" then oSheet.getCellByPosition(1,0).setValue(0)
	process_list = oSheet.getCellByPosition(1,0).getString()
	
	Statement = Connection.createStatement()
	ResultSet = Statement.executeQuery("SELECT hall_id,process_id, temperature FROM erp.hall where process_id in(" +process_list+ ") order by temperature DESC, process_id DESC,thickness ASC" )
	
			
	
	
		If Not IsNull(ResultSet) Then
	
			ResultSet.last   'Move to the LAST record, to determine the Record Count
			j = ResultSet.Row   'Added a variable with the number of records returned 
			ResultSet.beforeFirst()
			While ResultSet.next
	
				hall_id=ResultSet.getString(1)
				process_id=ResultSet.getString(2)
				temperature=ResultSet.getString(3)
	
				    sSQL= "SELECT process_id,temperature, depth, rsq, uh, ns/thickness*10000 AS ""nh, cm-3"", thickness, remarks, surveyor FROM erp.hall AS h WHERE process_id=" + process_id + "AND temperature="+temperature
				    ' I am using MakeProperty function written by DannyB, available in thousand references over this site, mean and clean. ;)
					vAttrib=Array(MakePropertyValue("DatabaseName", baza), MakePropertyValue( "SourceType", "SQL" ), MakePropertyValue( "SourceObject", sSQL))
	
					'Now the import, quick and nice. ;)
					oSheet.getcellbyposition(0,3+j).doImport(vAttrib)
					j=j-1
			Wend
		End If
	ResultSet.dispose()
	Connection.close()

end sub
'by DannyB
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   Dim oPropertyValue As New com.sun.star.beans.PropertyValue
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   EndIf
   If Not IsMissing( uValue ) Then
      oPropertyValue.Value = uValue
   EndIf
   MakePropertyValue() = oPropertyValue
End Function
Comment 1 Björn Michaelsen 2011-12-23 11:53:02 UTC
[This is an automated message.]
This bug was filed before the changes to Bugzilla on 2011-10-16. Thus it
started right out as NEW without ever being explicitly confirmed. The bug is
changed to state NEEDINFO for this reason. To move this bug from NEEDINFO back
to NEW please check if the bug still persists with the 3.5.0 beta1 or beta2 prereleases.
Details on how to test the 3.5.0 beta1 can be found at:
http://wiki.documentfoundation.org/QA/BugHunting_Session_3.5.0.-1

more detail on this bulk operation: http://nabble.documentfoundation.org/RFC-Operation-Spamzilla-tp3607474p3607474.html
Comment 2 Björn Michaelsen 2011-12-23 17:02:38 UTC
needinfo keyword redundant by needinfo status.
Comment 3 Alex Thurgood 2012-02-04 03:41:07 UTC
Hi,

There are too many factors here which need to be taken into account, please provide a sample Calc document containing macro and ODB file (using HSQLDB engine) so that it can be tested by others.

I don't really see what Java has to do with this, Basic access is not conditional on a functional Java environment, and you state you are using the native postgresql-sdbc driver, which is written in C.

The version of LibO you are using is also pretty old by now. Please try again with a current version, either 3.4.5 or the release candidate for 3.5.


Alex
Comment 4 K. 2012-03-22 01:10:26 UTC
This is fixed in version 3.5.1 of LibreOffice on Kubuntu 11.10. 
I am closing  this bug.