Bug 27628 - SequentialAccess flag on DataReader causes GetValues to fail with NullReferenceException
Summary: SequentialAccess flag on DataReader causes GetValues to fail with NullReferen...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: 3.12.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-04 01:45 UTC by Marc Melvin
Modified: 2018-02-22 22:33 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Marc Melvin 2015-03-04 01:45:23 UTC
I'm using SQL Server 2008 R2 SP3.

When attempting to use a SqlDataReader with SequentialAccess flag, the call to GetValues fails with a NullReferenceException. Removing SequentialAccess from ExecuteReader call solves the problem.

I discovered this issue while using the Dapper library, and have filed a ticket with them as well at the link below, but it appears this is an issue in the underlying Mono libraries due to it failing on an otherwise simple GetValues call passing in an array of null objects:
https://github.com/StackExchange/dapper-dot-net/issues/249

Thanks,
Marc
Comment 1 CoderPersonGuy 2015-07-07 18:47:06 UTC
I'm getting the following stack with SqlDataReader.  SequentialAccess is not being used but it is also in GetValue() so maybe the same bug:

Exception: NullReferenceException: Object reference not set to an instance of an object
  at System.Data.SqlClient.SqlDataReader.GetValues (System.Object[] values) <0x40984000 + 0x0006d> in <filename unknown>:0 
  at System.Data.ProviderBase.DataReaderContainer+CommonLanguageSubsetDataReader.GetValues (System.Object[] values) <0x40983f90 + 0x00029> in <filename unknown>:0 
  at System.Data.ProviderBase.SchemaMapping.LoadDataRow () <0x40983d90 + 0x00030> in <filename unknown>:0 
  at System.Data.Common.DataAdapter.FillLoadDataRow (System.Data.ProviderBase.SchemaMapping mapping) <0x40983910 + 0x00137> in <filename unknown>:0 
  at System.Data.Common.DataAdapter.FillFromReader (System.Data.DataSet dataset, System.Data.DataTable datatable, System.String srcTable, System.Data.ProviderBase.DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, System.Data.DataColumn parentChapterColumn, System.Object parentChapterValue) <0x4097d300 + 0x0011b> in <filename unknown>:0 
  at System.Data.Common.DataAdapter.Fill (System.Data.DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) <0x4097c920 + 0x00287> in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.FillInternal (System.Data.DataSet dataset, System.Data.DataTable[] datatables, Int32 startRecord, Int32 maxRecords, System.String srcTable, IDbCommand command, CommandBehavior behavior) <0x4097bcb0 + 0x0011c> in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) <0x4097b9f0 + 0x00173> in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable) <0x4097b740 + 0x000c2> in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Data.Common.DbDataAdapter:Fill (System.Data.DataTable)
Comment 2 CoderPersonGuy 2015-07-07 18:47:29 UTC
Mono JIT compiler version 4.3.0 (Nightly 4.3.0.342/ae2f50e Mon Jul  6 10:14:31 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
Comment 3 CoderPersonGuy 2015-07-07 18:48:59 UTC
Using SQL Server 2012
Comment 4 Marek Safar 2018-02-22 22:33:25 UTC
Mono 5.10 has significantly improved System.Data implementation which should resolve this issue. If you can still reproduce it please reopen the issue.