System.Data.SQLite
Check-in [dc86717583]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Implement a workaround for the issue described in ticket [9ac9862611].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-9ac9862611
Files: files | file ages | folders
SHA1: dc8671758339f015b58388e627dea48217a7f897
User & Date: mistachkin 2013-07-15 18:21:46
Context
2013-07-15
18:46
Implement a workaround for the issue described in ticket [9ac9862611]. check-in: f54929f54e user: mistachkin tags: trunk
18:21
Implement a workaround for the issue described in ticket [9ac9862611]. Closed-Leaf check-in: dc86717583 user: mistachkin tags: tkt-9ac9862611
07:08
Fix several issues with the managed virtual table support. Use the correct methods overloads for Marshal.PtrToStructure. Correct handling of native structure padding when running on 64-bit operating systems. Make sure connections released to the pool do not hold onto modules. Call sqlite3_dispose_module with the correct native module pointer. Modify all classes implementing the IDisposable pattern to set the disposed flag after their base classes have been disposed. Add LogExceptionsNoThrow and LogErrorsNoThrow to avoid throwing ObjectDisposedException when logging during derived class disposal. check-in: d60eb09374 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

   383    383   
   384    384             if (processorArchitecture != null)
   385    385                 return processorArchitecture;
   386    386   
   387    387             //
   388    388             // BUGBUG: Will this always be reliable?
   389    389             //
   390         -          return Environment.GetEnvironmentVariable(PROCESSOR_ARCHITECTURE);
          390  +          processorArchitecture = Environment.GetEnvironmentVariable(
          391  +              PROCESSOR_ARCHITECTURE);
          392  +
          393  +          //
          394  +          // HACK: Check for an "impossible" situation.  If the pointer size
          395  +          //       is 32-bits, the processor architecture cannot be "AMD64".
          396  +          //       In that case, we are almost certainly hitting a bug in the
          397  +          //       operating system and/or Visual Studio that causes the
          398  +          //       PROCESSOR_ARCHITECTURE environment variable to contain the
          399  +          //       wrong value in some circumstances.  Please refer to ticket
          400  +          //       [9ac9862611] for further information.
          401  +          //
          402  +          if ((IntPtr.Size == sizeof(int)) &&
          403  +              String.Equals(processorArchitecture, "AMD64",
          404  +                  StringComparison.OrdinalIgnoreCase))
          405  +          {
          406  +#if !NET_COMPACT_20 && TRACE_PRELOAD
          407  +              //
          408  +              // NOTE: When tracing is enabled, save the originally detected
          409  +              //       processor architecture before changing it.
          410  +              //
          411  +              string savedProcessorArchitecture = processorArchitecture;
          412  +#endif
          413  +
          414  +              //
          415  +              // NOTE: We know that operating systems that return "AMD64" as
          416  +              //       the processor architecture are actually a superset of
          417  +              //       the "x86" processor architecture; therefore, return
          418  +              //       "x86" when the pointer size is 32-bits.
          419  +              //
          420  +              processorArchitecture = "x86";
          421  +
          422  +              //
          423  +              // NOTE: Show that we hit a fairly unusual situation (i.e. the
          424  +              //       "wrong" processor architecture was detected).
          425  +              //
          426  +#if !NET_COMPACT_20 && TRACE_PRELOAD
          427  +              Trace.WriteLine(String.Format(
          428  +                  CultureInfo.CurrentCulture,
          429  +                  "Detected {0}-bit pointer size with processor architecture " +
          430  +                  "\"{1}\", using processor architecture \"{2}\" instead...",
          431  +                  IntPtr.Size * 8 /* bits */, savedProcessorArchitecture,
          432  +                  processorArchitecture));
          433  +#endif
          434  +          }
          435  +
          436  +          return processorArchitecture;
   391    437   #else
   392    438             //
   393    439             // NOTE: On the .NET Compact Framework, attempt to use the native
   394    440             //       Win32 API function (via P/Invoke) that can provide us with
   395    441             //       the processor architecture.
   396    442             //
   397    443             try