Control: tag -1 patch

On Wed, Mar 09, 2016 at 10:30:29AM +0100, Andreas Tille wrote:
> On Mon, Feb 22, 2016 at 09:50:41AM +0100, Michael Tautschnig wrote:
> > Control: severity -1 wishlist
> > Control: retitle -1 libfreecontact-perl: FTBFS when optimisation is disabled

> > Apologies for taking so long to get back to this one. I have now been able 
> > to
> > reproduce both the failing and the non-failing case. The key is to compile
> > with/without optimisation. Thus:

> Thanks for the clarification.  I wonder whether inside the Perl team
> some experiences exist regarding failures when doing no optimisation.

It's passing an uninitialized pointer to libfreecontact. Proposed patch 
attached.
-- 
Niko Tyni   nt...@debian.org
>From 4570fcae64c5f62ef1bf7558063064a60db62d0b Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Fri, 11 Mar 2016 11:25:59 +0200
Subject: [PATCH] Fix __timing initialization

When Perl code passes a 'timing' parameter that is not a hash reference,
for instance an undefined value, the '__timing' pointer passed to
libfreecontact needs to be explicitly initialized.

This fixes segmentation faults in t/02test.t when built
without optimization (gcc -O0).

Bug-Debian: https://bugs.debian.org/812626
---
 FreeContact.xsp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/FreeContact.xsp b/FreeContact.xsp
index b0c2497..f002df1 100644
--- a/FreeContact.xsp
+++ b/FreeContact.xsp
@@ -91,7 +91,10 @@ predictor::_run( __ali, __cp, __density, __gapth, __mincontsep, __pseudocnt, __p
     time_res_t timing;
   CODE:
     try {
-      if(items>=17 && SvROK(ST(16)) && SvTYPE(SvRV(ST(16))) == SVt_PVHV) __timing = &timing;
+      if(items>=17) {
+        if (SvROK(ST(16)) && SvTYPE(SvRV(ST(16))) == SVt_PVHV) __timing = &timing;
+        else __timing = NULL;
+      }
       RETVAL = THIS->run( __ali, __cp, __density, __gapth, __mincontsep, __pseudocnt, __pscnt_weight, __estimate_ivcov, __shrink_lambda, __cov20, __apply_gapth, __rho, __veczw, __num_threads, __icme_timeout, __timing );
     }
     catch (freecontact::icme_timeout_error& e)
@@ -116,7 +119,10 @@ predictor::_run_with_seq_weights(ali_t& __ali, freq_vec_t &__aliw, double __wtot
     time_res_t timing;
   CODE:
     try {
-      if(items>=17 && SvROK(ST(16)) && SvTYPE(SvRV(ST(16))) == SVt_PVHV) __timing = &timing;
+      if(items>=17) {
+        if (SvROK(ST(16)) && SvTYPE(SvRV(ST(16))) == SVt_PVHV) __timing = &timing;
+        else __timing = NULL;
+      }
       RETVAL = THIS->run( __ali, __aliw, __wtot,
         __density, __gapth, __mincontsep,
         __pseudocnt, __pscnt_weight, __estimate_ivcov, __shrink_lambda,
-- 
2.7.0

Reply via email to