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

Segfault on cout

Samuel_M_1
New Contributor I
450 Views

I'm compiling this very short program: 

 

#include <iostream>

using namespace std;

int main()
{
    size_t M = 500;
    size_t K = 2000;
    size_t N = 500;
    double A[M*K];
    double B[K*N];
    double C[M*N];
    cout << "sizeof C: " << sizeof(C) << "\n";
    return 0;
}

using this line: 

icpc example.cpp -o example

and it segfaults on the 'cout'.

This is my icpc verbose output: 

icpc -v example.cpp -o example
icpc version 14.0.0 (gcc version 4.2.1 compatibility)
/opt/intel/composer_xe_2013_sp1.0.074/bin/intel64/mcpcom    -_g -mP3OPT_inline_alloca -D__HONOR_STD -D__ICC=1400 -D__INTEL_COMPILER=1400 -D__INTEL_COMPILER_UPDATE=0 -D__BLOCKS__ -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int -D__WINT_TYPE__=int "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__GNUC_GNU_INLINE__ -D__GNUG__=4 -D__GNUC__=4 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__clang__=1 -D__clang_patchlevel__=0 -D__clang_minor__=0 -D__clang_major__=6 -D__clang_version__=6.0 -D__APPLE_CC__=5226 -D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=1095 -D__LITTLE_ENDIAN__ -D__DYNAMIC__ -D__private_extern__=extern -D__LP64__ -D_LP64 -D_GNU_SOURCE=1 -D__DEPRECATED=1 -D__GXX_WEAK__=1 -D__GXX_ABI_VERSION=1002 -D__USER_LABEL_PREFIX__=_ -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__EXCEPTIONS=1 -D__x86_64 -D__x86_64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D_MT -D__INTEL_COMPILER_BUILD_DATE=20130716 -D__PIC__ -D__APPLE__ -D__MACH__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE__ -D__MMX__ -_k -_8 -_l -_D -_a -_b --gnu_version=421 -_W5 --gcc-extern-inline -p --bool -tused -x --multibyte_chars --blocks --array_section --simd --simd_func --clang_extensions --bool -mP1OPT_version=14.0-intel64 -mGLOB_diag_file=/var/folders/xy/3h85g6tx0797nr4zf6k8gttr0000gn/T/icpce4cc5z.diag -mGLOB_diag_use_message_catalog=FALSE -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=421 "-mGLOB_options_string=-v -o example" -mGLOB_position_independent_code -mGLOB_preemption_model=1 -mGLOB_no_compact_unwind=TRUE -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/composer_xe_2013_sp1.0.074/bin/intel64 -mGLOB_as_output_backup_file_name=/var/folders/xy/3h85g6tx0797nr4zf6k8gttr0000gn/T/icpcLKDsBAas_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_em64t -mGLOB_instruction_tuning=0x0 -mGLOB_product_id_code=0x22006d8f -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x80 -mGLOB_advanced_optim=TRUE -mP3OPT_use_mspp_call_convention -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/composer_xe_2013_sp1.0.074/bin/intel64/libiml_attr.dylib -mIPOPT_obj_output_file_name=/var/folders/xy/3h85g6tx0797nr4zf6k8gttr0000gn/T/icpce4cc5z.o -mIPOPT_whole_archive_fixup_file_name=/var/folders/xy/3h85g6tx0797nr4zf6k8gttr0000gn/T/icpcwarchBxiNAe -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mGLOB_driver_tempfile_name=/var/folders/xy/3h85g6tx0797nr4zf6k8gttr0000gn/T/icpctempfiletNPRI1 -mGLOB_os_target=GLOB_OS_TARGET_MACH -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/var/folders/xy/3h85g6tx0797nr4zf6k8gttr0000gn/T/icpce4cc5z.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_C_PLUS_PLUS -mP1OPT_source_file_name=example.cpp -mGLOB_eh_linux example.cpp
#include "..." search starts here:
#include <...> search starts here:
 /opt/intel/composer_xe_2013_sp1.0.074/compiler/include/intel64
 /opt/intel/composer_xe_2013_sp1.0.074/compiler/include
 /usr/include/c++/4.2.1
 /usr/include/c++/4.2.1/backward
 /System/Library/Frameworks
 /Library/Frameworks
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include
 /usr/local/include
 /usr/include
End of search list.
ld    -lcrt1.10.6.o -dynamic -arch x86_64 -weak_reference_mismatches non-weak -macosx_version_min 10.9.5 -no_compact_unwind -o example -L/opt/intel/composer_xe_2013_sp1.0.074/compiler/lib -L/usr/lib /var/folders/xy/3h85g6tx0797nr4zf6k8gttr0000gn/T/icpce4cc5z.o /opt/intel/composer_xe_2013_sp1.0.074/compiler/lib/libimf.a /opt/intel/composer_xe_2013_sp1.0.074/compiler/lib/libsvml.a /opt/intel/composer_xe_2013_sp1.0.074/compiler/lib/libirng.a /opt/intel/composer_xe_2013_sp1.0.074/compiler/lib/libipgo.a /opt/intel/composer_xe_2013_sp1.0.074/compiler/lib/libdecimal.a -weak-lcilkrts -lstdc++ -lSystem /opt/intel/composer_xe_2013_sp1.0.074/compiler/lib/libirc.a /opt/intel/composer_xe_2013_sp1.0.074/compiler/lib/libsvml.a /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a

I'm on Mac OS X 10.9.5 - can anyone explain why this would be happening?

0 Kudos
1 Solution
Samuel_M_1
New Contributor I
450 Views

Nevermind, I guess it is just blowing out the stack as noted here: 

https://software.intel.com/en-us/articles/intel-fortran-compiler-increased-stack-usage-of-80-or-higher-compilers-causes-segmentation-fault

I'm exceeding the 8MB limit. A specific error message about that would be nice. 

View solution in original post

0 Kudos
2 Replies
Samuel_M_1
New Contributor I
451 Views

Nevermind, I guess it is just blowing out the stack as noted here: 

https://software.intel.com/en-us/articles/intel-fortran-compiler-increased-stack-usage-of-80-or-higher-compilers-causes-segmentation-fault

I'm exceeding the 8MB limit. A specific error message about that would be nice. 

0 Kudos
Shenghong_G_Intel
450 Views

yes...it is expected error as you defined very large stack variables arrays, which will lead to this error. You should also get same error with other compilers like GCC/Clang. This is the behavior of OS, so, it is impossible for compiler to report a specific error message. :)

On Linux, you can use "ulimit" to check the limitation settings.

 

Thanks,

Shenghong

0 Kudos
Reply