ODBCDatabase causing segmentation fault

I have an Ubuntu installation, it has been running a WEB application successfully for months. There is connectivity code to a Microsoft SQL server built into the WEB code that has been functioning successfully. So now I am in need of daemon process to post SQL data as it comes in from another source. So I created a console application, and the first step was to make sure it could establish the SQL connection. I copied the working code from the WEB application and pasted it into the new project. At the point I try to establish a connection, I get a dump, Segmentation fault (core dumped). EVEN IF I surround the connect with Try - Catch - End Try.
I’m really puzzled, cause a WEB app is almost the same technically as a console application, it is running on the same Ubuntu server…

dbConnect is a Property of the application declared as DataClass, a class I copied from the WEB application to the standalone console application.
dbServer is a Property of the DataClass declared as ODBCDatabase

DataClass.LogonDatabase (method)

[code]Dim sDataSource As String
Dim bReturn As Boolean

If (dbServer = Nil) Then
dbServer = New ODBCDatabase
End If
sDataSource = “Driver=/usr/lib/i386-linux-gnu/odbc/libtdsodbc.so; Server=; Port=1433; TDS_Version=8.0; dbName=OUTSIDE; UID=sauser; PWD=sapassword”
dbServer.DataSource = sDataSource

bReturn = dbServer.Connect '<— Code crashes here SegFault
Print “Connect caused an exception”+Chr(13)
End Try

Return bReturn[/code]

A seg fault is not something you’ll be able to catch with a try catch
It’s a hard crash

If you run your console app in a terminal window do you get any errors or messages before the crash ?
Not sure if the core file has anything useful but it might if you file that short snippet + the core file in a feedback bug report.

Hi Norman,
No there is no indication, and now many times the OS doesn’t even report the Segment Fault, the program just ceases and returns to the shell.
Is there a test connection string? I’ve tried eliminating the Driver= and try just any connection string without using FreeTDS, but everything or anything in there seems to just crash it. It’s almost like ODBCDatabase plugin is the issue.
The permissions of chown is root:root, chmod is 777 for the app, and all includes in the library directory. (wtf Libs)
Running the app from the shell using: sudo ./wtf (new app name)
I’ve created a new app and made it really bare bones with just a Run event:

[code] Dim dbServer As ODBCDatabase
Dim bConnected As Boolean
Dim sDataSource As String

If (dbServer = Nil) Then
dbServer = NEW ODBCDatabase
End If

sDataSource = “Provider=SQLOLEDB;Server=;Database=SecureView;”
dbServer.DataSource = sDataSource

Print “Im here”+Chr(13)
bConnected = dbServer.Connect

If (bConnected) Then
Print “DB Connected Successfully”+Chr(13)
Print “No Connection”+Chr(13)
End If[/code]

I get “Im here” then back to shell.

Well, using blank ("") DataSource string does not crash it. But, of course that also will not connect. Placing garbage in there “asdf” will still crash it rather than reporting some sort of error.

…more… I still do not know why it crashes, or doesn’t report that my gibberish string couldn’t be found. I have now made sure /etc/odbc.ini has a properly configured DSN, /etc/odbcinst.ini knows to Free TDS and it is configured properly. Have tested it using the shell command:
isql SecureView sauser sapassword
I can connect in the shell and properly query the database. Also my WEB application still functions properly on the same server connecting to the same SQL server.
I have now tried eliminating the full connection string from DataSource and reduced it to:

dbServer.DataSource = "SecureView" dbServer.UserName = "sauser" dbServer.Password = "sapass"

It still crashes without reporting an error.
Both the WEB and my standalone console application are compiled with the same version 2012/R3.3,
The rights and permissions to both the WEB application and my console are the same.

Total loss… :-/

Just out of curiosity, what’s the user that is running the daemon? And does that user have the correct permissions with regards to the app?

Have you checked the system logs in /var/log for those segfault messages? There may be other clues there.

The user has admin rights. When I run as that user, I see the “Segmentation fault (core dumped)”. It is when I run it as superuser, (sudo ./wtf) then it just crashes without any error indication.

Not sure what I’m looking at in the logs, there is an apport.log which is showing:
called for pid 5730, signal 11
executable: /var/XoJo/wtf (command line “./wtf”)
is_closing_session(): no DBUS_SESSION_BUS_ADDRESS in environment

From what I’ve just been reading (http://www.freedesktop.org/wiki/Software/dbus/), the DBUS_SESSION_BUS_ADDRESS environment vars are usually set in user login scripts. DBUS is sometimes used to simplify the daemonization process, so it wouldn’t surprise me if it’s required.

So how are you invoking the daemon? Maybe that will give us some clues.

I haven’t gotten that far yet. Eventually I was thinking of changing the super to ServiceApplication and invoking it on startup.

Right now, it is just being run from the console shell prompt. Very basic app, just to test the SQL connectivity.
sudo ./wtf

This Ubuntu install is very basic without a GUI.

Have you run ?

ldd wtf

That would tell you if something is missing from the machine.

Oh, and are your web app and your console app built with the same version of the IDE?

Hi Greg,
ldd didn’t show much…

And both were compiled…

Both the WEB and my standalone console application are compiled with the same version 2012/R3.3,

Let me correct that XoJo is version 2013/R3.3. (not 2012).

Norman, Greg…
Thanks for trying to help. This is completely baffling me; and I have given up. I have written a Windows Service Console App to run in the background of 4 workstations to handle the job.
Is it because I have an older version and there was a known issue? I am using FreeTDS because there is no official MS-SQL-Database for linux. Has this type of SQL connection (Linux to MS-SQL) been tried in the lab? Should I be using something else? (But it works on WEB!) I read the ODBCDatabase instructions for non windows, went to iODBC and tried using that – First it conflicts with the libraries for FreeTDS so that was trashed, and I never got that working either… plus my WEB application died without FreeTDS and I couldn’t get iODBC working there either; so uninstalled and went back to FreeTDS.
I admit, I’m no Linux expert and I know there will be quarks in cross platform development, but it has certainly left me feeling – I’d like to feel like XoJo was my goto language for any OS.

Have you tried a newer version of the IDE?

Hi Greg,
No not yet, I will when I get some time, been working on other pressing projects and hate when code that works breaks with a newer IDE compile. I do have another issue with WebListBox not accepting user input which I’m hoping has been fixed in a newer IDE release so it is on my to do list regarding these Ubuntu machines.

Version 2014/R3.1 - Corrected the issue.