<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>11058</bug_id>
          
          <creation_ts>2017-02-15 17:12:41 +0000</creation_ts>
          <short_desc>Debugging with GDB causes Segmentation Fault</short_desc>
          <delta_ts>2017-02-16 14:41:02 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>devtools / tool chain</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>arm</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>OBSOLETE</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alex">olddudealex</reporter>
          <assigned_to name="Paul Eggleton">bluelightning</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>70717</commentid>
    <comment_count>0</comment_count>
    <who name="Alex">olddudealex</who>
    <bug_when>2017-02-15 17:12:41 +0000</bug_when>
    <thetext>I cross-compiled the app,that uses boost::asio library, and tested it on my target system. It works properly. But when I try to debug my app with gdb, I get this message in gdb-console:
**************************************************
Program received signal SIGSEGV, Segmentation fault.
_dl_debug_initialize (ldbase=4294967292, ns=1996288212) at dl-debug.c:55
55           if (r-&gt;r_map == NULL || ldbase != 0)
**************************************************
The result is the same for remote and native debugging, and for several other boost libraries (but not for all).

After searching any information, that could be helpful, I found similar problem in this doc (p.63): http://support.garz-fricke.com/products/Santaro/Linux-Yocto/Releases/Yocto-jethro-5.1-r6859-0/GUF-Yocto-jethro-5.1-r6859-0-IMX6GUF-Manual.pdf

As said in document the problem can be caused by &quot;Static instanciation in implicitly implemented C++ methods&quot; and is connected to glibc. So I 
tried to reproduce this bug by this approach with code:
*************************************************
#include &lt;iostream&gt;

using namespace std;

class AClass
{
public:
  void foo()
  {
    static int NmbOfInvokes = 0;
    NmbOfInvokes++;
    cout &lt;&lt; NmbOfInvokes &lt;&lt; endl;
  }
};

int main(void)
{
  cout &lt;&lt; &quot;Hello World&quot; &lt;&lt; endl;

  AClass anInstance;
  anInstance.foo();
  anInstance.foo();

  return 0;
}
*************************************************
This program works properly, but in debugging fails with the same SIGSEGV error.

To fix it enough to rewrite class AClass in this way:
*************************************************
class AClass
{
public:
  void foo();
};

void AClass::foo()
{
  static int NmbOfInvokes = 0;
  NmbOfInvokes++;
  cout &lt;&lt; NmbOfInvokes &lt;&lt; endl;
}
*************************************************

The compilation flags:
*************************************************
arm-poky-linux-gnueabi-g++  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -DHAVE_CONFIG_H -I. -I..   --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi  -g -O0  --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -MT SegFault_Reproduce.o -MD -MP -MF .deps/SegFault_Reproduce.Tpo -c -o SegFault_Reproduce.o SegFault_Reproduce.cpp
mv -f .deps/SegFault_Reproduce.Tpo .deps/SegFault_Reproduce.Po
../arm-poky-linux-gnueabi-libtool  --tag=CXX   --mode=link arm-poky-linux-gnueabi-g++  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi  -g -O0  --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi  --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -o SegFault_Reproduce SegFault_Reproduce.o  
arm-poky-linux-gnueabi-libtool: link: arm-poky-linux-gnueabi-g++ -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -g -O0 --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi --sysroot=/opt/fsl-imx-x11/4.1.15-1.2.0/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi -o SegFault_Reproduce SegFault_Reproduce.o 
*************************************************

I suppose that in some boost libraries are used similar static instanciation, because the symptoms are exactly the same.
I use yocto 2.0.1 with gcc 5.2.0, gdb 7.9.1, boost 1.58</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70737</commentid>
    <comment_count>1</comment_count>
    <who name="Alex">olddudealex</who>
    <bug_when>2017-02-16 14:41:02 +0000</bug_when>
    <thetext>After updating GDB to 7.11.1 version the problem has gone.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>