-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/13/2010 06:43 AM, Nikolaus Rath wrote:
> Yeah, I'm around. I don't know what an "exact disassembly" is or how to
> provide one, but if someone tells me what to do then I'm most likely
> willing to do it.

We can test the hypothesis very easily.  Find line 15472 in the
amalgamation.  A few lines up there should be #ifdef SQLITE_MUTEX_PTHREADS.
 Put "volatile" as a prefix for the nRef and owner declarations.

  volatile int nRef;                  /* Number of entrances */
  volatile pthread_t owner;           /* Thread that is within this mutex */

Please let us know the results and I'll update the ticket.

> Correct. Also, it only happens when apsw is compiled with -g.

The amalgamation is being used when you compiled APSW.  When you compile
APSW with debug and the amalgamation, two things happen.  Firstly assertions
are turned on in both APSW and SQLite.  These are put in by the programmers
and verify that the internal state matches expectations (for example that a
particular code path will not be called unless a flag is set, or that when
one internal routine calls another it will never pass zero as a parameter).
 This is very helpful when developing new code, major modifications to
existing code and running the test suites.

Secondly it enables SQLITE_DEBUG.  This enables a lot of extra code in
SQLite doing such things as enabling detailed tracing, and more heavyweight
checking which includes mutexes.  This is an additional layer of helpfulness
for developing the code and test suites.  The existing mutex checking debug
code allows the compiler more scope for optimisation but will give the wrong
answer if threading happens at "unlucky" points.  volatile prevents the
compiler from making those optimisations.

When using assertions and SQLITE_DEBUG you should see at least a 30%
performance hit because of all the extra checking.

There is no reason to enable the assertions or SQLITE_DEBUG unless you
strongly believe there is an uncaught bug in the code (especially internal
routines calling other internal routines) that hasn't been caught by
existing test suites.  Those kind of bugs are far easier to detect by source
code review.

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvsPUkACgkQmOOfHg372QTI9wCfRgBNgU4nMwLaQa3uJKxZ3Ffs
/XYAoJgxkSl7nfEoTEG1m9Mzj4sDLazI
=sOFw
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to