Download it now!
Bug 37167 - JDBC/HSQLDB: Null pointer exception when executing a prepared statement with no arguments
Summary: JDBC/HSQLDB: Null pointer exception when executing a prepared statement with ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
3.3.2 release
Hardware: All All
: medium normal
Assignee: Lionel Elie Mamane
URL:
Whiteboard: target:4.3.0 target:4.1.5 target:4.2.1
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-13 02:23 UTC by Bernhard Donaubauer
Modified: 2014-01-08 15:20 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
picture of the error report (11.93 KB, image/png)
2011-05-13 02:23 UTC, Bernhard Donaubauer
Details
Database contains one table and one little macro "testmacro" that throws this exception (4.73 KB, application/vnd.oasis.opendocument.database)
2011-07-15 03:44 UTC, Bernhard Donaubauer
Details
Database register dialog (20.95 KB, image/png)
2011-07-18 00:25 UTC, Bernhard Donaubauer
Details
hs_err_pid (140.36 KB, text/x-log)
2013-12-31 16:44 UTC, Julien Nabet
Details
bt (16.13 KB, text/plain)
2013-12-31 17:32 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Donaubauer 2011-05-13 02:23:20 UTC
Created attachment 46671 [details]
picture of the error report

Hallo,

I programed a little basic macros for one of my users. This macro worked with gooo-3.1 for years. Now we deployed LibreOffice. Unfortunately LibreOffice throws a null pointer exception within this macro.

Here is an excerpt of my BASIC macro:

dbContext=createUnoService("com.sun.star.sdb.DatabaseContext")
dataSource=dbContext.getByName("internetplz")

handler = createUnoService("com.sun.star.sdb.InteractionHandler")
connection = dataSource.ConnectWithCompletion(handler)

stmt=connection.prepareCall("execute procedure adm_an_adm('"+alteAdmNr+"','"+neueAdmNr+"');")

stmt.execute()

stmt.close()

connection.close()


The stmt.execute() gives me a null pointer exception.

As an aside, I found a similar report concerning OO3.2 (which we left out)
http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=29579&start=0


Regards,
Bernhard Donaubauer
Comment 1 Petr Mladek 2011-05-23 12:07:36 UTC
Noel, does it trigger any bell?
Comment 2 Noel Power 2011-05-24 02:50:51 UTC
(In reply to comment #1)
> Noel, does it trigger any bell?

sorry, nope, if there was a standalone example it might be possible to get some more details.  Currently all we can tell is that some java null pointer problem is getting passed up to the bridge and then to basic.
Comment 3 Bernhard Donaubauer 2011-07-15 03:42:30 UTC
Hello,

I know I am late but I had a lot of work to do and was ill for some time but here is the standalone example bugShow.odb.
Comment 4 Bernhard Donaubauer 2011-07-15 03:44:20 UTC
Created attachment 49130 [details]
Database contains one table and one little macro "testmacro" that throws this exception
Comment 5 Noel Power 2011-07-15 09:11:12 UTC
well not being really that familiar with base, is there some recommended way to run macros from base, I just opened the odb, opened the basic ide and ran the testmacro, it fails for me on the following line

dataSource=dbContext.getByName("bugShow")

where an exception ( no such element ) is thrown, the only names dbContext in this instance knows about are Bibliography, so... I think I am missing some step, any hints?
Comment 6 Bernhard Donaubauer 2011-07-18 00:25:18 UTC
Created attachment 49233 [details]
Database register dialog

You have to register the odb - File.

See the picture.
Comment 7 Björn Michaelsen 2011-12-23 12:01:37 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 8 Bernhard Donaubauer 2012-03-01 00:12:27 UTC
Tested it with:

LibreOffice 3.5.0rc3 
Build-ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735


Problem is still there!
Comment 9 Alex Thurgood 2012-03-01 00:29:17 UTC
Adding myself to cc, will try and find some time to look at this.


Alex
Comment 10 Florian Reisinger 2012-08-14 14:01:24 UTC
Dear bug submitter!

Due to the fact, that there are a lot of NEEDINFO bugs with no answer within the last six months, we close all of these bugs.

To keep this message short, more infos are available @ https://wiki.documentfoundation.org/QA/NeedinfoClosure#Statement

Thanks for understanding and hopefully updating your bug, so that everything is prepared for developers to fix your problem.

Yours!

Florian
Comment 11 Florian Reisinger 2012-08-14 14:02:29 UTC
Dear bug submitter!

Due to the fact, that there are a lot of NEEDINFO bugs with no answer within the last six months, we close all of these bugs.

To keep this message short, more infos are available @ https://wiki.documentfoundation.org/QA/NeedinfoClosure#Statement

Thanks for understanding and hopefully updating your bug, so that everything is prepared for developers to fix your problem.

Yours!

Florian
Comment 12 Florian Reisinger 2012-08-14 14:07:06 UTC
Dear bug submitter!

Due to the fact, that there are a lot of NEEDINFO bugs with no answer within the last six months, we close all of these bugs.

To keep this message short, more infos are available @ https://wiki.documentfoundation.org/QA/NeedinfoClosure#Statement

Thanks for understanding and hopefully updating your bug, so that everything is prepared for developers to fix your problem.

Yours!

Florian
Comment 13 Florian Reisinger 2012-08-14 14:09:11 UTC
Dear bug submitter!

Due to the fact, that there are a lot of NEEDINFO bugs with no answer within the last six months, we close all of these bugs.

To keep this message short, more infos are available @ https://wiki.documentfoundation.org/QA/NeedinfoClosure#Statement

Thanks for understanding and hopefully updating your bug, so that everything is prepared for developers to fix your problem.

Yours!

Florian
Comment 14 Alex Thurgood 2012-08-15 07:13:16 UTC
Florian,

Am re-opening as unconfirmed, will test later today, then report back. The original submitter has given us enough information to test, at least for those of us who know Base, so its rather unfair to state that we needmoreinfo unless we've actually tested.


Alex
Comment 15 Alex Thurgood 2012-08-15 07:18:34 UTC
Confirming : I can reproduce the behaviour on LO 3.4.4 on Linux Mint 12 64bit, will try with other versions and try and get a trace from a debug build if it is still present in one of the latest builds.


Alex
Comment 16 Alex Thurgood 2012-08-15 08:13:14 UTC
Confirming also in LibreOffice 3.5.5.2 
Build ID: 24b32b4-b87ec2e-85c8e98-87a4e20-9a1b8c1



Alex
Comment 17 Alex Thurgood 2012-08-15 08:13:54 UTC
Changing platform to All as reproducible on Linux as well.


Alex
Comment 18 Alex Thurgood 2012-08-15 10:40:59 UTC
Confirming also on 3.6.0.4 Linux 64bit Mint 12
Comment 19 Alex Thurgood 2012-08-15 11:19:09 UTC
Running gdb

When I click on Run Macro from the Tools > Macros menu, I see this :

Program received signal SIGSEGV, Segmentation fault.
0x00007fffbc45ae86 in ?? ()
(gdb) 
(gdb) 
(gdb) 
(gdb) cc
Undefined command: "cc".  Try "help".
(gdb) bt
#0  0x00007fffbc45ae86 in ?? ()
#1  0x00000000fb2d49a2 in ?? ()
#2  0x000000000000001b in ?? ()
#3  0x0000000000000000 in ?? ()
Comment 20 Alex Thurgood 2012-08-15 11:26:52 UTC
If I press continue in gdb, I get the Macro Selector dialog, and can navigate
down to the macro included in the ODB file. Now, when I click on "Run" :

(gdb) c
Continuing.
[New Thread 0x7fffc82d5700 (LWP 2576)]
[Thread 0x7fffc82d5700 (LWP 2576) exited]
[New Thread 0x7fffc82d5700 (LWP 2600)]
[New Thread 0x7fffc4199700 (LWP 2601)]
[New Thread 0x7fffc62d1700 (LWP 2604)]
[Thread 0x7fffc62d1700 (LWP 2604) exited]
[New Thread 0x7fffc62d1700 (LWP 2606)]
[Thread 0x7fffc62d1700 (LWP 2606) exited]
c
[New Thread 0x7fffc62d1700 (LWP 2612)]
[Thread 0x7fffc62d1700 (LWP 2612) exited]
c
Program received signal SIGSEGV, Segmentation fault.
0x00007fffbc45ae86 in ?? ()


So doesn't seem to be of much help there.


Alex
Comment 21 Alex Thurgood 2012-08-15 11:30:20 UTC
Unfortunately, apparently no debug symbols in the 3.6.0.4 version I was testing.

Alex
Comment 22 Alex Thurgood 2012-08-15 20:47:35 UTC
Downloaded the daily x86_64 from August 13th, 2012, i.e. future 3.6.1 - no debug symbols are provided, so bt attempt worthless :-/ - this is where doing qa becomes a PITA.

Alex
Comment 23 Alex Thurgood 2012-08-15 20:51:28 UTC
@Lionel
Assigning to you as it seems to be a Base problem at heart, but if you feel it is more of UNO Basic problem, then please re-assign.

I've also changed component to Database, if you feel that's wrong, please change back.


Alex
Comment 24 Noel Power 2012-08-15 21:30:27 UTC
Nah, it's not a Basic nor UNO problem as far as I can see, seems it is either a problem with the macro ( I can't tell ) or more likely an implementation issue in the associated UNO base related objects. I can see gets as far as 

 228 sal_Bool java_lang_Object::callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const
 229 {
 230     jboolean out( sal_False );
 231 
 232     SDBThreadAttach t;
 233     OSL_ENSURE( t.pEnv, "java_lang_Object::callBooleanMethod: no Java enviroment anymore!" );
 234     obtainMethodId(t.pEnv, _pMethodName,"()Z", _inout_MethodID);
 235     // call method
 236     out = t.pEnv->CallBooleanMethod( object, _inout_MethodID );
 237     ThrowSQLException( t.pEnv, NULL );

and the exception is generated based on the contents of t.pEnv from the JNI call at 236. Interestingly 'object' seems to be null there ( surely that should be something ? ) but since I know approx. zero about either base or JNI I can't be sure. 

#0  connectivity::java_lang_Object::callBooleanMethod (this=0x2460bb8, _pMethodName=0x7f0a0937baa7 "execute", _inout_MethodID=@0x7f0a095aabe8) at /media/FreeAgent-4/LIBOO-master/core/connectivity/source/drivers/jdbc/Object.cxx:237
#1  0x00007f0a09364055 in connectivity::java_sql_PreparedStatement::execute (this=0x2460b30) at /media/FreeAgent-4/LIBOO-master/core/connectivity/source/drivers/jdbc/PreparedStatement.cxx:100
#2  0x00007f0a2336cb39 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, unsigned int, double*, unsigned int) () from /media/FreeAgent-4/LIBOO-master/core/INSTALL_LINK/ure/lib/libgcc3_uno.so
#3  0x00007f0a2336e5bc in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, _typelib_TypeDescriptionReference*, int, _typelib_MethodParameter*, void*, void**, _uno_Any**) () from /media/FreeAgent-4/LIBOO-master/core/INSTALL_LINK/ure/lib/libgcc3_uno.so
Comment 25 Julien Nabet 2013-12-31 16:44:25 UTC
Created attachment 91371 [details]
hs_err_pid

On pc Debian x86-64 with master sources updated today, I gave a try and had a crash while running the macro step by step.
I attached error

I noticed too these kinds of logs:
warn:basic.sbx:19947:1:basic/source/sbx/sbxvalue.cxx:192: Not at Parent-Prop - otherwise CyclicRef
warn:legacy.osl:19947:1:dbaccess/source/ui/uno/dbinteraction.cxx:65: BasicInteractionHandler::BasicInteractionHandler: enabling legacy behavior, there should be no clients of this anymore!
java.lang.NullPointerException
warn:legacy.osl:19947:1:unotools/source/config/moduleoptions.cxx:635: unknown factory
Comment 26 Julien Nabet 2013-12-31 17:32:33 UTC
Created attachment 91374 [details]
bt

I attached bt when I'm trying look at the content of stmt variable in "watch pane" just after this:
stmt=connection.prepareCall("update mytable set text='aaa';")
Comment 27 Julien Nabet 2013-12-31 17:40:28 UTC
the SQL update mytable set text='aaa'; from the macro doesn't even work.

Lionel: any idea?
Comment 28 Julien Nabet 2014-01-01 15:15:32 UTC
About update queries, it seems only SELECT can work according to these:
http://opengrok.libreoffice.org/xref/core/dbaccess/source/core/api/SingleSelectQueryComposer.cxx#checkForSingleSelect_throwError and http://opengrok.libreoffice.org/xref/core/dbaccess/source/core/resource/strings.src#73
     73 String RID_STR_ONLY_QUERY
     74 {
     75     Text [ en-US ] = "The given command is not a SELECT statement.\nOnly queries are allowed.";
     76 };
Comment 29 Lionel Elie Mamane 2014-01-06 15:52:42 UTC
Bernhard, for your information here is how you can avoid having to register the datasource:

dataSource = ThisDatabaseDocument.DataSource

Also, "com.sun.star.sdb.InteractionHandler" is deprecated. It is recommended to switch to "com.sun.star.task.InteractionHandler".

And BTW here's an even better way to connect to the current database:

	Dim DBDocUI as Object
	DBDocUI = ThisDatabaseDocument.currentController
	if not DBDocUI.isConnected then
		DBDocUI.connect
	end if
	stmt = DBDocUI.ActiveConnection.createStatement/prepareStatement/prepareCall(...)
Comment 30 Commit Notification 2014-01-06 16:11:34 UTC
Lionel Elie Mamane committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=01329972d89ddfd30d197b7947c571fdb83b0cf8

fdo#37167 create statement before execute/wasNull/getBoolean



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 31 Lionel Elie Mamane 2014-01-06 16:21:11 UTC
Backport to 4.1 & 4.2 submitted for review in gerrit:
 https://gerrit.libreoffice.org/7280/
 https://gerrit.libreoffice.org/7281/
Comment 32 Lionel Elie Mamane 2014-01-06 16:23:05 UTC
(In reply to comment #27)
> the SQL update mytable set text='aaa'; from the macro doesn't even work.
> 
> Lionel: any idea?

Need to quote the table and column names:

 UPDATE "mytable" SET "text"='aaa';

in the macro:

 connection.prepareCall("UPDATE ""mytable"" SET ""text""='aaa';")
Comment 33 Commit Notification 2014-01-08 15:18:55 UTC
Lionel Elie Mamane committed a patch related to this issue.
It has been pushed to "libreoffice-4-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=515c6cf7a3832bfc7a6eeed65704bc9eee96adc1&h=libreoffice-4-1

fdo#37167 create statement before execute/wasNull/getBoolean


It will be available in LibreOffice 4.1.5.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 34 Commit Notification 2014-01-08 15:20:13 UTC
Lionel Elie Mamane committed a patch related to this issue.
It has been pushed to "libreoffice-4-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=85cf6f6f210eaf427ff91d59325122eb7a4e54d1&h=libreoffice-4-2

fdo#37167 create statement before execute/wasNull/getBoolean


It will be available in LibreOffice 4.2.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.