[Bug c++/77772] New: Segmentation fault when running an application with gdb

antonio.poggiali at datalogic dot com gcc-bugzilla@gcc.gnu.org
Wed Sep 28 09:41:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77772

            Bug ID: 77772
           Summary: Segmentation fault when running an application with
                    gdb
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antonio.poggiali at datalogic dot com
  Target Milestone: ---

Created attachment 39712
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39712&action=edit
Logs, command line and temp file with GCC 5.2.0

Host system:
Linux APoggialiNpVb-lx 3.13.0-95-generic #142-Ubuntu SMP Fri Aug 12 17:00:09
UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Target system:
ARM cortex A5
Linux <my machine name> 4.1.0-linux4sam_5.2-00045-g633e08a-dirty #1 Wed Aug 31
16:22:02 CEST 2016 armv7l GNU/Linux

Cross-compiler invocation, output and temp file in attachment (5.2.0.tar.gz).

The compiler is generated from Yocto Poky (jethro):

arm-poky-linux-gnueabi-g++ (GCC) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Comment:

 If I deploy the application on the target and launch it, everything is fine
(return value is zero).

 If I debug the application using gdbserver+gdb, I get a segmentation fault on
the glibc library (see logs in attachment).

Working system:

 Cross compiling with GCC 4.9.3 toward a glibc 2.20 stub (generated from Yocto
Poky (dizzy)), I am able to run and debug successfully on the target. Note that
the target system is not changed and still have the glibc 2.22 shared object
(/lib/libc-2.22.so). Cross-compiler invocation, output and temp file in
attachment (4.9.3.tar.gz).

Trick to have the debugger working:

 If I change the code from this:

>> class _my_class
>> {
>> public:
>> 
>> 	// Return empty string
>> 	static char *get_empty_string()
>> 	{
>> 		static char empty_string = '\0';
>> 		return &empty_string;
>> 	}
>> };
>> 
>> char _my_class::empty_string = '\0';

  to this:

>> class _my_class
>> {
>> public:
>> 
>> 	static char empty_string;
>> 
>> 	// Return empty string
>> 	static char *get_empty_string()
>> 	{
>> 		return &empty_string;
>> 	}
>> };
>> 
>> char _my_class::empty_string = '\0';

then everything works fine even with GCC 5.2.0.


More information about the Gcc-bugs mailing list