This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Re: Disable -lmcheck when Python has threads (Re: [BUG] gdb crash when "python import gtk")


On Thu, 30 Aug 2012 18:00:46 +0200, Khoo Yit Phang wrote:
> 2012-08-30  Khoo Yit Phang  <khooyp@cs.umd.edu>

This patch does not seem to require copyright assignment but it would be safer
to complete one for example from Sergio Durigan Junior <sergiodj@redhat.com>.
Also for any possible future contributions.


> 	Disable -lmcheck when Python is enabled with threading support.
> 	* configure.ac: Move --enable-lmcheck after --with-python, and
> 	disable if python_has_threads=yes.

Describe it more technically, new variable python_has_threads, check
${python_prog} --has-threads etc.


[...]
> +# Provide a --enable-libmcheck/--disable-libmcheck set of options
> +# allowing a user to enable this option even when building releases,
> +# or to disable it when building a snapshot.
> +AC_ARG_ENABLE(libmcheck,
> +  AS_HELP_STRING([--enable-libmcheck],
> +                 [Try building GDB with -lmcheck if available]),
> +  [case "${enableval}" in
> +     yes | y) ENABLE_LIBMCHECK="yes" ;;
> +     no | n)  ENABLE_LIBMCHECK="no" ;;
> +     *) AC_MSG_ERROR(bad value ${enableval} for --enable-libmcheck) ;;
> +   esac])
> +
> +# Enable -lmcheck by default (it provides cheap-enough memory mangling),
> +# but turn it off for releases.
> +if test -z "${ENABLE_LIBMCHECK}" && $development; then
> +  ENABLE_LIBMCHECK=yes
> +fi
> +
> +if test "$ENABLE_LIBMCHECK" = "yes" ; then
> +  if test "${have_libpython}" != "no" -a "${python_has_threads}" = "yes" ; then
> +    AC_MSG_WARN(libmcheck disabled since python has threads)
> +  else
> +    AC_CHECK_LIB(mcheck, main)
> +  fi
> +fi

I am fine with this goal of disabling -lmcheck by default (when
--enable-libmcheck was not specified) when threaded libpython is linked in.

But when user explicitly specifies --enable-libmcheck it should give the
warning but still enable libmcheck.  In most of the uses of GDB libmcheck is
safe with GDB.


> --- a/gdb/python/python-config.py
> +++ b/gdb/python/python-config.py
> @@ -1,5 +1,5 @@
>  # Program to fetch python compilation parameters.
> -# Copied from python-config of the 2.7 release.
> +# Copied from python-config of the 2.7 release, modified to test for threads.

Please submit it also for Python.  The commit in GDB sources is OK as long as
it gets imported by upstream Python.  They may also suggest some other
solution if they do not agree with this one.


Thanks for catching it.


Jan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]