Created attachment 14426 [details]
Sample that causes the Exception, needs to be linked to System.Data
Mono 4.2.0 from openSUSE Tumbleweed or Mono built from github
A Program that uses ODBC to connect to a PostgreSQL Database with the DSN Psql_testdb (any Db should work, though) and makes a simple SELECT.
What do I expect:
My Program lists all tables.
ExecuteReader() throws an EntryPointNotFoundException:
at (wrapper managed-to-native) System.Data.Common.SafeNativeMethods:LocalAlloc (int,intptr)
at System.Data.ProviderBase.DbBuffer..ctor (Int32 initialSize, Boolean zeroBuffer) [0x00033] in /home/abuild/rpmbuild/BUILD/mono-4.2.1/external/referencesource/System.Data/System/Data/ProviderBase/DbBuffer.cs:37
at System.Data.ProviderBase.DbBuffer..ctor (Int32 initialSize) [0x00000] in /home/abuild/rpmbuild/BUILD/mono-4.2.1/external/referencesource/System.Data/System/Data/ProviderBase/DbBuffer.cs:45
at System.Data.Odbc.CNativeBuffer..ctor (Int32 initialSize) [0x00000] in /home/abuild/rpmbuild/BUILD/mono-4.2.1/external/referencesource/System.Data/System/Data/Odbc/OdbcUtils.cs:20
at System.Data.Odbc.OdbcCommand.GetStatementHandle () [0x00039] in /home/abuild/rpmbuild/BUILD/mono-4.2.1/external/referencesource/System.Data/System/Data/Odbc/OdbcCommand.cs:387
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject (CommandBehavior behavior, System.String method, Boolean needReader, System.Object methodArguments, SQL_API odbcApiMethod) [0x0001c] in /home/abuild/rpmbuild/BUILD/mono-4.2.1/external/referencesource/System.Data/System/Data/Odbc/OdbcCommand.cs:552
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject (CommandBehavior behavior, System.String method, Boolean needReader) [0x00022] in /home/abuild/rpmbuild/BUILD/mono-4.2.1/external/referencesource/System.Data/System/Data/Odbc/OdbcCommand.cs:531
at System.Data.Odbc.OdbcCommand.ExecuteReader (CommandBehavior behavior) [0x0000a] in /home/abuild/rpmbuild/BUILD/mono-4.2.1/external/referencesource/System.Data/System/Data/Odbc/OdbcCommand.cs:515
at System.Data.Odbc.OdbcCommand.ExecuteReader () [0x00000] in /home/abuild/rpmbuild/BUILD/mono-4.2.1/external/referencesource/System.Data/System/Data/Odbc/OdbcCommand.cs:509
at (wrapper remoting-invoke-with-check) System.Data.Odbc.OdbcCommand:ExecuteReader ()
at OdbcTest.MainClass.Main (System.String args) [0x00027] in /home/<me>/Dokumente/CSharp/OdbcTest/OdbcTest/Program.cs:15
LocalAlloc appears to be in ExternDll.Kernel32.
I have the same issue: it seems there is no corresponding implementation for LocalAlloc in https://github.com/mono/mono/blob/master/mono/metadata/marshal.c (mono_win32_compat_LocalAlloc is missing)
Created attachment 14449 [details]
A patch that uses Marshal instead os SafeNativeMethods
This path makes DbBuffer use Marshal where it previously relied on Kernel32.
PtrToStringUni(int offset) might now go out of the actually allocated space, previously it would have done weird stuff on characters that take 32 bits and gone out of buffer space in lstrlenW.
I too am running into the same error but using unixODBC w/IBM DB2 for i (dsdriver).
I had the same problem so I recompiled mono with patch provided by Lars Hollenbach and I have linked the new System.Data.dll to my project.
The patch does not work because now I'im falling into Seg fault !
I think the correct fix is adding mono_win32_compat_LocalAlloc just like other mono_win32_compat_* implementions. Then, a reference to that call has to be added to the config file just like the ones already added for others mono_win32_compat_* methods.
I'm not sure how this new mono_win32_compat_LocalAlloc method should be implemented. Maybe just wrapping a call to malloc would do the job.
Any update on the issue, I am using Mono 4.2.0 on Ubuntu 16.04LTS . ODBC with DB2, Sybase, Oracle, MS SQL Server
All with the error as described above.
How to solve it?
On Sun Solaris 11.3 compiled Mono4.2.0. the same issue as Linux, ODBCcommand.ExecuteReader failed.
CommandObject.ExecuteReader are all good
CommandObject.ExecuteReader broken with System.EntryPointNotFoundException: LocalAlloc ?
Just apply the same logic code to System.Data.Odbc
IBM.Data.DB2 or System.Data.OracleClient or System.Data.SqlClient
It should be fixed !!!
I can confirm this as well
# mono -V
Mono JIT compiler version 4.4.2 (Stable 188.8.131.52/f72fe45 Fri Jul 29 09:58:49 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
LLVM: supported, not enabled.
same problem here with odbc connector and 184.108.40.206. Is there any planned fix for this?
Are there any workarounds yet? Or any news on a planned fix yet?
I have the same problem, I can't update to 16.04, used to work fine on 14.04.
I really need it !!
the ODBC stuff as well as the whole System.Data is currently moving to corefx sources.
I'm also having this problem, and have not yet been able to come up with a workaround. Using older versions of mono has been suggested, but I run into issues when attempting to install the older versions of the mod-mono package found in those snapshot repos. This seems to be a fairly major problem that has been around for almost 2 years now.
What is the status of the port of System.Data? And what does it mean that System.Data is currently moving to corefx sources? Is this no longer going to be something supported in Mono and we'll need to start using the new .NET Core? That has a number of it's own limitations that would prevent it's use for my application in particular, and I'm sure others are in the same boat. Is this the end of ODBC support entirely? How was it working previously, and why can't that functionality be put back in place?