Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

C++11 in-class initialization lead to crash

Bert_Jonson
Beginner
2,382 Views

[cpp]

#include <stdio.h>

static struct {
    const char *s = "abcd";
} a;

int main() {
    printf("%s", a.s);
}
[/cpp]

GCC works correctly on it, when exe produced by icc crashes.

ICC 13.1 on win.

There is too many fails with ICC and today none of my bugreports was fixed, it has awful support of C++11 features, also no information about next release of ICC, so i'm moving to GCC.

0 Kudos
38 Replies
bernaske
New Contributor I
869 Views

Hi iliyapolak,

<<< It always pays off to learning some debugging magic:) >>>

yes, shure , but its great i love debugging its the great part of programming :-)

best regards

Franz

0 Kudos
Bernard
Valued Contributor I
869 Views

>>>yes, shure , but its great i love debugging its the great part of programming :-)>>>

Completely agree with you.What debugger do you use?Is this gdb?

0 Kudos
Bernard
Valued Contributor I
869 Views

>>>yes, shure , but its great i love debugging its the great part of programming :-)>>>

Completely agree with you.What debugger do you use?Is this gdb?

0 Kudos
SergeyKostrov
Valued Contributor II
869 Views
>>now the g++/gcc executable produce the SIGSEGV on folllow: >> >>Program received signal SIGSEGV, Segmentation fault. >>0x00007ffff72893a4 in __GI__IO_default_xsputn (f=0x7fffffffd260, data=, n=4) >> at genops.c:476 >>476 *p++ = *s++; >>... What test case did you use? Could you post it? Sorry, I'm a little bit confused about that new problem and please provide the test case.
0 Kudos
bernaske
New Contributor I
869 Views

Hi Sergey, Hi iliyapolak,

yes as debugger i use gdb or DDD, also the IDB for Parallel Studio XE 2013,

Sergey as testcase i use the sample from the begin from Bert Jonson

best regards

Franz

0 Kudos
Bernard
Valued Contributor I
869 Views
>>>yes as debugger i use gdb or DDD, also the IDB for Parallel Studio XE 2013,>>> Have you ever had any experience with windbg?
0 Kudos
JenniferJ
Moderator
869 Views

An update to this issue. 

The next major release of icl (tested on Windows) works with this test.  The beta is not started yet. But if you're interested in our beta program, let me know. 

Jennifer 

0 Kudos
SergeyKostrov
Valued Contributor II
869 Views
>>...testcase i use the sample from the begin from Bert Jonson... I see. >>...The next major release of icl (tested on Windows) works with this test... Do you mean Update 3 or Update 4? Please clarify. Thanks.
0 Kudos
bernaske
New Contributor I
869 Views

Hi iliyapolak,

>>> Have you ever had any experience with windbg? <<<

no, we only works with Linux ( openSUSE 12.3, and SUSE SLES 11 SP2 Server )

best regards

Franz

0 Kudos
Bernard
Valued Contributor I
869 Views
>>>no, we only works with Linux ( openSUSE 12.3, and SUSE SLES 11 SP2 Server )>>> I sometimes envy you because you are working with open source OS and have access to source code.
0 Kudos
bernaske
New Contributor I
869 Views

Hi iliyapolak,

i have compile the sample with icpc 13.1 and with gcc-7.2,  now then i debug with gdb, i think its maybe possible a bug in icpc 13.1

see debug output icpc exec:

gdb) s
1310      outstring ((const UCHAR_T *) format,
(gdb) s
1314      if (*f == L_('\0'))
(gdb) s
1318      if (__builtin_expect (__printf_function_table != NULL
(gdb) s
264       void *args_malloced = NULL;
(gdb) s
261       int readonly_format = 0;
(gdb) s
1295      nspecs_done = 0;
(gdb) s
1287      grouping = (const char *) -1;
(gdb) s
227       const char *thousands_sep = NULL;
(gdb) s
1366          JUMP (*++f, step0_jumps);
(gdb) s
1363          workend = &work_buffer[sizeof (work_buffer) / sizeof (CHAR_T)];
(gdb) s
1362          workstart = NULL;
(gdb) s
1345          int alt = 0;      /* Alternate format.  */
(gdb) s
1346          int space = 0;    /* Use space prefix if no sign is needed.  */
(gdb) s
1347          int left = 0;     /* Left-justify output.  */
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7057434 in _IO_vfprintf_internal (s=<optimized out>, format=<optimized out>, ap=ap@entry=0x7fffffffd368)
    at vfprintf.c:1629
1629              process_string_arg (((struct printf_spec *) NULL));
(gdb)

and now the gcc-4.7.2 exec:

       int main() {
8           printf("%s", a.s);
9       }
(gdb) b 8
Breakpoint 1 at 0x400620: file c_11.c, line 8.
(gdb) r
Starting program: /ibm_supercomputing/testprg/c_11_g

Breakpoint 1, main () at c_11.c:9
9       }
(gdb) s
__printf (format=0x4006e9 "%s") at printf.c:29
29      {
(gdb) s
33        va_start (arg, format);
(gdb) s
29      {
(gdb) s
34        done = vfprintf (stdout, format, arg);
(gdb) s
33        va_start (arg, format);
(gdb) s
34        done = vfprintf (stdout, format, arg);
(gdb) s
_IO_vfprintf_internal (s=0x7ffff75b9160 <_IO_2_1_stdout_>, format=0x4006e9 "%s", ap=ap@entry=0x7fffffffd378)
    at vfprintf.c:257
257       int save_errno = errno;
(gdb) s
222     {
(gdb) s
257       int save_errno = errno;
(gdb) c
Continuing.
abcd[Inferior 1 (process 4766) exited normally]
(gdb)

what think you about ?

best regards

Franz

0 Kudos
Bernard
Valued Contributor I
869 Views

Hi Franz,

It is very hard to read the code because of awful formatting.

0 Kudos
Bernard
Valued Contributor I
869 Views

>>>0x00007ffff7057434 in _IO_vfprintf_internal (s=<optimized out>, format=<optimized out>, ap=ap@entry=0x7fffffffd368)
    at vfprintf.c:1629
1629              process_string_arg (((struct printf_spec *) NULL));>>>

It looks like the routine above at line of code#1629 caused segmentation fault.It seems like null pointer is passed (cast) as a parameter to function call process_string_arg()

0 Kudos
Bernard
Valued Contributor I
869 Views

My last response trigerred anti-spam filter.

I think that the function call at code line 1629 is responsible for segmentation fault.The parameter is null pointer which is cast to some struct type pointer.

0 Kudos
SergeyKostrov
Valued Contributor II
869 Views
Hi Franz, The problem was already reported by Jennifer and there is nothing else we could do here because Intel software engineers have plenty of information about the problem. Honestly, I consider all these debugging excersises as unnecessary ( What are you looking for? ). Of course, you could do whatever you want but unless sources of Intel C++ compiler are fixed only a workaround could help. Thanks for your time. Best regards, Sergey
0 Kudos
Bernard
Valued Contributor I
869 Views

Hi Franz,

Is GDB also kernel mode debugger with the similar capabilities as windbg?I mean kernel debugging over serial port, usb and firewire.

0 Kudos
Bert_Jonson
Beginner
869 Views

Hi, Jennifer.

I'm intrested in yours beta program and sent a message to you, but there is no answer.

Maybe it's forum mistake. One way or another, please, let me know.

Regards.

0 Kudos
JenniferJ
Moderator
869 Views

Update to this issue. It is fixed in the 13.x branch, and the fix should be available in the next update.

About the Beta, please read this posting and join the beta, and submit issues.

Thank you!
Jennifer

0 Kudos
Reply