Commit Graph

16 Commits

Author SHA1 Message Date
Matt Jordan 4a58261694 git migration: Refactor the ASTERISK_FILE_VERSION macro
Git does not support the ability to replace a token with a version
string during check-in. While it does have support for replacing a
token on clone, this is somewhat sub-optimal: the token is replaced
with the object hash, which is not particularly easy for human
consumption. What's more, in practice, the source file version was often
not terribly useful. Generally, when triaging bugs, the overall version
of Asterisk is far more useful than an individual SVN version of a file. As a
result, this patch removes Asterisk's support for showing source file
versions.

Specifically, it does the following:

* Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and
  remove passing the version in with the macro. Other facilities
  than 'core show file version' make use of the file names, such as
  setting a debug level only on a specific file. As such, the act of
  registering source files with the Asterisk core still has use. The
  macro rename now reflects the new macro purpose.

* main/asterisk:
  - Refactor the file_version structure to reflect that it no longer
    tracks a version field.
  - Remove the "core show file version" CLI command. Without the file
    version, it is no longer useful.
  - Remove the ast_file_version_find function. The file version is no
    longer tracked.
  - Rename ast_register_file_version/ast_unregister_file_version to
    ast_register_file/ast_unregister_file, respectively.

* main/manager: Remove value from the Version key of the ModuleCheck
  Action. The actual key itself has not been removed, as doing so would
  absolutely constitute a backwards incompatible change. However, since
  the file version is no longer tracked, there is no need to attempt to
  include it in the Version key.

* UPGRADE: Add notes for:
  - Modification to the ModuleCheck AMI Action
  - Removal of the "core show file version" CLI command

Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
2015-04-13 03:48:57 -04:00
Richard Mudgett 308c1b41dd DEBUG_THREADS: Fix regression and lock tracking initialization problems.
This patch started with David Lee's patch at
https://reviewboard.asterisk.org/r/2826/ and includes a regression fix
introduced by the ASTERISK-22455 patch.

The initialization of a mutex's lock tracking structure was not protected
in a critical section.  This is fine for any mutex that is explicitly
initialized, but a static mutex may have its lock tracking double
initialized if multiple threads attempt the first lock simultaneously.

* Added a global mutex to properly serialize initialization of the lock
tracking structure.  The painful global lock can be mitigated by adding a
double checked lock flag as discussed on the original review request.

* Defer lock tracking initialization until first use.

* Don't be "helpful" and initialize an uninitialized lock when
DEBUG_THREADS is enabled.  Debug code is not supposed to fix or change
normal code behavior.  We don't need a lock initialization race that would
force a re-setup of lock tracking.  Lock tracking already handles
initialization on first use.

* Properly handle allocation failures of the lock tracking structure.

* No need to initialize tracking data in __ast_pthread_mutex_destroy()
just to turn around and destroy it.


The regression introduced by ASTERISK-22455 is the result of manipulating
a pthread_mutex_t struct outside of the pthread library code.  The
pthread_mutex_t struct seems to have a global linked list pointer member
that can get changed by other threads.  Therefore, saving and restoring
the contents of a pthread_mutex_t struct is a bad thing.

Thanks to Thomas Airmont for finding this obscure regression.

* Don't overwrite the struct ast_lock_track.reentr_mutex member to restore
tracking data in __ast_cond_wait() and __ast_cond_timedwait().  The
pthread_mutex_t struct must be treated as a read-only opaque variable.


Miscellaneous other items fixed by this patch:

* Match ast_suspend_lock_info() with ast_restore_lock_info() in
__ast_cond_timedwait().

* Made some uninitialized lock sanity checks return EINVAL and try a
DO_THREAD_CRASH.

* Fix bad canlog initialization expressions.

ASTERISK-24614 #close
Reported by: Thomas Airmont

Review: https://reviewboard.asterisk.org/r/4247/
Review: https://reviewboard.asterisk.org/r/2826/
........

Merged revisions 429539 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@429541 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-12-12 23:49:36 +00:00
Richard Mudgett c8ebf3e3c7 Revert -r411073. It didn't help and blew up the system.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411087 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-25 15:47:17 +00:00
Richard Mudgett 89e12de79d locking: Add temporary sanity checks.
Add some temporary sanity checks to hunt for locking problems with the
masquerade supertest.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411073 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-24 23:36:36 +00:00
David M. Lee c2e6e1ef49 Fix DEBUG_THREADS when lock is acquired in __constructor__
This patch fixes some long-standing bugs in debug threads that were
exacerbated with recent Optional API work in Asterisk 12.

With debug threads enabled, on some systems, there's a lock ordering
problem between our mutex and glibc's mutex protecting its module list
(Ubuntu Lucid, glibc 2.11.1 in this instance). In one thread, the module
list will be locked before acquiring our mutex. In another thread, our
mutex will be locked before locking the module list (which happens in
the depths of calling backtrace()).

This patch fixes this issue by moving backtrace() calls outside of
critical sections that have the mutex acquired. The bigger change was to
reentrancy tracking for ast_cond_{timed,}wait, which wrongly assumed
that waiting on the mutex was equivalent to a single unlock (it actually
suspends all recursive locks on the mutex).

(closes issue ASTERISK-22455)
Review: https://reviewboard.asterisk.org/r/2824/
........

Merged revisions 398648 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 398649 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 398651 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398652 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-09 20:13:40 +00:00
Richard Mudgett 46b9e5450f Fix memory corruption when trying to get "core show locks".
Review https://reviewboard.asterisk.org/r/2580/ tried to fix the mismatch
in memory pools but had a math error determining the buffer size and
didn't address other similar memory pool mismatches.

* Effectively reverted the previous patch to go in the same direction as
trunk for the returned memory pool of ast_bt_get_symbols().

* Fixed memory leak in ast_bt_get_symbols() when BETTER_BACKTRACES is
defined.

* Fixed some formatting in ast_bt_get_symbols().

* Fixed sig_pri.c freeing memory allocated by libpri when MALLOC_DEBUG is
enabled.

* Fixed __dump_backtrace() freeing memory from ast_bt_get_symbols() when
MALLOC_DEBUG is enabled.

* Moved __dump_backtrace() because of compile issues with the utils
directory.

(closes issue ASTERISK-22221)
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/2778/
........

Merged revisions 397525 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 397528 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397570 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-23 18:07:40 +00:00
Kevin Harwell 2eebab3992 Fix for segfault in __ast_rwlock_destroy with DEBUG_THREADS
If DEBUG_THREADS is enabled __ast_rwlock_destroy causes a segfault while trying
to access a possible NULL t->track object.  A NULL check has been added before
trying to access the memory.

(closes issue ASTERISK-21724)
Reported by: Corey Farrell
Fixed by: Corey Farrell
Patches:
	ast_rwlock_destroy-segv.patch uploaded by Corey Farrell (license 5909)
........

Merged revisions 388838 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 388839 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388840 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-15 15:58:56 +00:00
Matthew Jordan 588e90a4d9 Re-initialize logmsgs mutex upon logger initialization to prevent lock errors
Similar to the patch that moved the fork earlier in the startup sequence to
prevent mutex errors in the recursive mutex surrounding the read/write thread
registration lock, this patch re-initializes the logmsgs mutex.  Part of the
start up sequence before forking the process into the background includes
reading asterisk.conf; this has to occur prior to the call to daemon in order
to read startup parameters.  When reading in a conf file, log statements can
be generated.  Since this can't be avoided, the mutex instead is
re-initialized to ensure a reset of any thread tracking information.

This patch also includes some additional debugging to catch errors when
locking or unlocking the recursive mutex that surrounds locks when the
DEBUG_THREADS build option is enabled.  DO_CRASH or THREAD_CRASH will
cause an abort() if a mutex error is detected.

(issue ASTERISK-19463)
Reported by: mjordan
Tesetd by: mjordan
........

Merged revisions 376586 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 376587 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 376588 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@376589 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-23 00:02:23 +00:00
David M. Lee 05fd2ef0a6 Fixes ast_rwlock_timed[rd|wr]lock for BSD and variants.
The original implementations simply wrap pthread functions, which take
absolute time as an argument. The spinlock version for systems without
those functions treated the argument as a delta. This patch fixes the
spinlock version to be consistent with the pthread version.

(closes issue ASTERISK-20240)
Reported by: Egor Gorlin
Patches:
	lock.c.patch uploaded by Egor Gorlin (license 6416)
........

Merged revisions 371718 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 371720 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371721 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-08-27 16:56:56 +00:00
Kevin P. Fleming 166b4e2b30 Multiple revisions 369001-369002
........
  r369001 | kpfleming | 2012-06-15 10:56:08 -0500 (Fri, 15 Jun 2012) | 11 lines
  
  Add support-level indications to many more source files.
  
  Since we now have tools that scan through the source tree looking for files
  with specific support levels, we need to ensure that every file that is
  a component of a 'core' or 'extended' module (or the main Asterisk binary)
  is explicitly marked with its support level. This patch adds support-level
  indications to many more source files in tree, but avoids adding them to
  third-party libraries that are included in the tree and to source files
  that don't end up involved in Asterisk itself.
........
  r369002 | kpfleming | 2012-06-15 10:57:14 -0500 (Fri, 15 Jun 2012) | 3 lines
  
  Add a script to enable finding source files without support-levels defined.
........

Merged revisions 369001-369002 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 369005 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369013 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-15 16:20:16 +00:00
Kinsey Moore c5b3db1956 Kill off red blobs in most of main/*
Everything still compiled after making these changes, so I assume these
whitespace-only changes didn't break anything (and shouldn't have).


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360190 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-22 19:51:16 +00:00
Terry Wilson 632cd26411 Merged revisions 314358 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r314358 | twilson | 2011-04-19 22:25:15 -0700 (Tue, 19 Apr 2011) | 4 lines
  
  Initialize track pointer
  
  ast_reentrancy_init checks to see if it is NULL before initializing with calloc
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@314359 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-04-20 05:28:36 +00:00
Tilghman Lesher fc4df44bd8 Merged revisions 307142 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r307142 | tilghman | 2011-02-08 23:39:39 -0600 (Tue, 08 Feb 2011) | 3 lines
  
  Initialize tracking variable in structure properly.  Fixes a memory leak.
  (Reported by The_Boy_Wonder on IRC, fixed by me.)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@307143 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-09 05:53:29 +00:00
Tilghman Lesher 16c3ea3d42 Merged revisions 304950 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r304950 | tilghman | 2011-01-31 00:41:36 -0600 (Mon, 31 Jan 2011) | 18 lines
  
  Change mutex tracking so that it only consumes memory in the core mutex object when it's actually being used.
  
  This reduces the overall size of a mutex which was 3016 bytes before this back
  down to 216 bytes (this is on 64-bit Linux with a glibc-implemented mutex).
  The exactness of the numbers here may vary slightly based upon how mutexes are
  implemented on a platform, but the long and short of it is that prior to this
  commit, chan_iax2 held down 98MB of memory on a 64-bit system for nothing more
  than a table of 32767 locks.  After this commit, the same table occupies a mere
  7MB of memory.
  
  (closes issue #18194)
   Reported by: job
   Patches: 
         20110124__issue18194.diff.txt uploaded by tilghman (license 14)
   Tested by: tilghman
   
  Review: https://reviewboard.asterisk.org/r/1066
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@304951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-31 06:50:49 +00:00
Russell Bryant 90ac07ce45 Attempt to fix FreeBSD build problem.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@269569 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-06-09 23:56:08 +00:00
Jason Parker 9e3f5fa6fb Remove ABI differences that occured when compiling with DEBUG_THREADS.
"Bad Things" would happen if Asterisk was compiled with DEBUG_THREADS, but a
loaded module was not (or vice versa).  This also immensely simplifies the
lock code, since there are no longer 2 separate versions of them.

Review: https://reviewboard.asterisk.org/r/508/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@258557 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-22 19:08:01 +00:00