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

Possible bug in inlined string functions of icc Version 11.1 (Build 20090511 Package ID: l_cproc_p_11.1.038)

wolfgang-svrcek-seil
378 Views
Hi all,
When I compile the following program:

#include
#include

int main()
{
char x[100];
int len;

strcpy(x, "mumbo jumbo");
len = (int) strlen(x);
printf("%d\n", len);
return 0;
}

with icc 11.1 and optimization level -O2 or higher, valgrind complains about numerous runtime errors, most probably initially triggered triggered
inside strlen(). If, however, I compile it with '-nolib-inline', all error messages are gone.
Besides, compiling with icc 10.1 or 11.0 also gives no errors.

I hope that helps,
greetings,
Andreas



0 Kudos
4 Replies
Brandon_H_Intel
Employee
378 Views
Hi all,
When I compile the following program:

#include
#include

int main()
{
char x[100];
int len;

strcpy(x, "mumbo jumbo");
len = (int) strlen(x);
printf("%dn", len);
return 0;
}

with icc 11.1 and optimization level -O2 or higher, valgrind complains about numerous runtime errors, most probably initially triggered triggered
inside strlen(). If, however, I compile it with '-nolib-inline', all error messages are gone.
Besides, compiling with icc 10.1 or 11.0 also gives no errors.

I hope that helps,
greetings,
Andreas




I'll take a look at this. What command line are you using for valgrind?
0 Kudos
wolfgang-svrcek-seil
378 Views
Hi,
thanks for the quick reply. The submitted example is a close to minimal test case.
Command lines:
icc tstr.c -g -O2
...
valgrind ./a.out | & less
valgrind versio is 3.3.0, flags enabled by default are: -v --trace-children=yes --time-stamp=yes --error-limit=no --leak-check=full
--leak-resolution=high

best,
Andreas
0 Kudos
Brandon_H_Intel
Employee
378 Views
Hi,
thanks for the quick reply. The submitted example is a close to minimal test case.
Command lines:
icc tstr.c -g -O2
...
valgrind ./a.out | & less
valgrind versio is 3.3.0, flags enabled by default are: -v --trace-children=yes --time-stamp=yes --error-limit=no --leak-check=full
--leak-resolution=high

best,
Andreas


Looks like this is a known limitation of valgrind. See http://valgrind.org/docs/manual/dist.news.html under Known Limitations:

- Memcheck is unusable with the Intel compiler suite version 11.1, when it generates code for SSE2-and-above capable targets. This is because of icc's use of highly optimised inlined strlen implementations. It causes Memcheck to report huge numbers of false errors even in simple programs. Helgrind and DRD may also have problems.


If you're using the compiler for 32-bit, you can use the -mia32 option to workaround this, but this optionwill likely impact your performance.
0 Kudos
Patrick_Lopresti
Beginner
378 Views

This was actually a deficiency in Valgrind; it gets confused by aligned vector loads that extend past the end of an allocated memory block.

https://bugs.kde.org/show_bug.cgi?id=294285

This deficiency is fixed in (soon-to-be-released) Valgrind 3.9.0 and above. If you use that version of Valgrind and run your test case with "--partial-loads-ok=yes", you should find it works now.

0 Kudos
Reply