openCL clCreateProgramWithBinary generates munmap_chunk() error inside a C++ program -


i´m trying fpga altera opencl libraries have use soc opencl. have cross compile application , have done. in fact software has many parts , it´s bit difficult follow. fact if cross compile alone opencl code working program. when insert code inside program munmap_chunk error can´t understand. when use gdb received error when line executed:

program = clcreateprogramwithbinary(context, 1, &device, (const size_t *)&binary_size, (const unsigned char **)&binary_buf, &binary_status, &status_ocl);

returns error: *** error in `../../bin/linux-arm/hpsfpga1dtest': munmap_chunk(): invalid pointer: 0x00294a98 *****

so can´t info reason why happening. code being executed (i can show function init, code longer).

what have done execute program valgrind. gives info, problem don´t quite understand it. valgrind show errors don´t know how fix them. attach valgrind output. ask understanding valgrind in order fix memory issue. lot help!!

/***********************/ /* opencl runtime configuration , function prototypes */ /***********************/ // runtime constants // used define work set on kernel execute. static const size_t work_group_size = 10;  // 8 threads in demo     workgroup // defines kernel argument value, workitem id // execute printf call static const int thread_id_to_output = 2;  // opencl runtime configuration static cl_platform_id platform = null; static cl_device_id device = null; static cl_context context = null; static cl_command_queue queue_p = null; static cl_command_queue queue_c = null; static cl_kernel kernel_p = null; static cl_kernel kernel_c = null; static cl_program program = null;  // function prototypes  bool init(); void cleanup(); static void device_info_ulong( cl_device_id device, cl_device_info param,     const char* name); static void device_info_uint( cl_device_id device, cl_device_info param, const char* name); static void device_info_bool( cl_device_id device, cl_device_info param, const char* name); static void device_info_string( cl_device_id device, cl_device_info param, const char* name); static void display_device_info( cl_device_id device );  file    *fp; char filename[] = "./hello_world.aocx"; //rhs 29/06/2017 change name hello_world.aocx adc.aocx give better explanation  cl_int i_ocl;   int j=0; /* rhs 29/06/17: opencl parameters. if afterwards have driver,     erase code , use driver api */ // function prototypes // entry point. /**********************************************************************************************************************/ /* end of opencl parameters */ /************************************************************************    **********************************************/  /*****************************************************************/ /*      opencl auxiliary functions          **/ /*****************************************************************/ bool init() {   cl_int status;   size_t binary_size;   char *binary_buf;  cl_int binary_status;    cl_uint num_kernels;   char kernel_name[30];   cl_kernel *kernels;    if(!setcwdtoexedir()) {     return false;   }    // opencl platform.   platform = findplatform("altera");   if(platform == null) {     printf("error: unable find altera opencl platform.\n");     return false;   }    // user-visible output - platform information   {     char char_buffer[string_buffer_len];      printf("querying platform info:\n");     printf("==========================\n");     clgetplatforminfo(platform, cl_platform_name, string_buffer_len, char_buffer, null);     printf("%-40s = %s\n", "cl_platform_name", char_buffer);     clgetplatforminfo(platform, cl_platform_vendor, string_buffer_len, char_buffer, null);     printf("%-40s = %s\n", "cl_platform_vendor ", char_buffer);     clgetplatforminfo(platform, cl_platform_version, string_buffer_len, char_buffer, null);     printf("%-40s = %s\n\n", "cl_platform_version ", char_buffer);   }    // query available opencl devices.   scoped_array<cl_device_id> devices;   cl_uint num_devices;    devices.reset(getdevices(platform, cl_device_type_all, &num_devices));    // we'll use first device.   device = devices[0];    // display device information.   display_device_info(device);    // create context.   context = clcreatecontext(null, 1, &device, null, null, &status);   checkerror(status, "failed create context");    // create command queue.   queue_p = clcreatecommandqueue(context, device,     cl_queue_profiling_enable, &status);   checkerror(status, "failed create command queue_p");   queue_c = clcreatecommandqueue(context, device,     cl_queue_profiling_enable, &status);   checkerror(status, "failed create command queue_c");    // create program.      printf("open...\n\n");     fp = fopen(filename, "r");     if(!fp){         fprintf(stderr, "failed load kernel. \n");         exit(1);     }      printf("reading content...\n\n");     binary_buf = (char *)malloc(max_binary_size+1);      printf("reading content: done\n\n");     binary_size = fread(binary_buf,sizeof(char), max_binary_size, fp);     fclose(fp);  program = clcreateprogramwithbinary(context, 1, &device, (const size_t *)&binary_size, (const unsigned char **)&binary_buf, &binary_status, &status);      // build program created.   status = clbuildprogram(program, 0, null, "", null, null);   checkerror(status, "failed build program");    // create kernel - name passed in here must match kernel name in   // original cl file, compiled aocx file using aoc tool   //printf("push key continue: ");   //scanf("%d");   const char *kernel_name_c = "consumer";  // kernel names, defined in cl file    //determining number of kernels   if (clcreatekernelsinprogram(program, 0, null, &num_kernels) < 0){     printf("could not find kernels");     exit(1);   }   kernels = (cl_kernel*)malloc(num_kernels*sizeof(cl_kernel));   //creating kernels   clcreatekernelsinprogram(program, num_kernels, kernels, null);   printf("\nthere %d kernels in hello_world program\n", num_kernels);    //finding kernels consumer   for(int = 0; i<=num_kernels; i++){      clgetkernelinfo(kernels[i], cl_kernel_function_name,sizeof(kernel_name), kernel_name, null);      //else if(strcmp(kernel_name, "consumer") == 0){     if(strcmp(kernel_name, "consumer") == 0){         printf("found consumer kernel @ index %d \n", i);         kernel_c = kernels[i];         break;     }   }     clgetkernelinfo(kernel_c, cl_kernel_function_name,  sizeof(kernel_name), kernel_name, null);     printf("\nkernel_c is: %s\n", kernel_name);   return true; } 

here output of valgrind. part think it´s more important , don´t understand is:
==183== invalid read of size 4 ==183== @ 0x56a3258: std::string::_rep::_m_dispose(std::allocator const&) (in /usr/lib/libstdc++.so.6.0.20) ==183== address 0x5aa0a64 4 bytes before block of size 20 alloc'd ==183== @ 0x484625c: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-arm-linux.so)

and whole valgrind output:

==183== memcheck, memory error detector ==183== copyright (c) 2002-2015, , gnu gpl'd, julian seward et al. ==183== using valgrind-3.11.0 , libvex; rerun -h copyright info ==183== command: ../../bin/linux-arm/hpsfpga1dtest st.cmd ==183== parent pid: 117 ==183==  --183--  --183-- valgrind options: --183--    --track-origins=yes --183--    --show-mismatched-frees=yes --183--    --vgdb=full --183--    -v --183--    --log-file=valgrind_out.txt --183-- contents of /proc/version: --183--   linux version 3.13.0 (dte@ubuntu) (gcc version 4.9.4 (buildroot 2017.05-rc2) ) #1 smp sun jun 11 13:02:19 cest 2017 --183--  --183-- arch , hwcaps: arm, littleendian, armv7-neon-vfp --183-- page sizes: 4096, max supported 4096 --183-- valgrind library directory: /usr/lib/valgrind --183-- reading syms /opt/epics/support/areadetector/adhps_fpga_1d/iocs/hpsfpga1dioc/bin/linux-arm/hpsfpga1dtest --183-- warning: dicfsi 0x0 .. 0xf outside mapped rx segments (none) --183-- warning: dicfsi 0x10 .. 0x2f outside mapped rx segments (none) --183-- reading syms /lib/ld-2.23.so --183--   reading exidx entries: 18 available ==183==   warning: whilst reading exidx: extabentrydecode: failed error code: -10 ==183==   warning: whilst reading exidx: extabentrydecode: failed error code: -10 ==183==   warning: whilst reading exidx: extabentrydecode: failed error code: -10 --183--   reading exidx entries: 17 attempted, 14 successful --183-- reading syms /usr/lib/valgrind/memcheck-arm-linux --183--    object doesn't have symbol table --183--    object doesn't have dynamic symbol table --183--   reading exidx entries: 1 available --183--   reading exidx entries: 0 attempted, 0 successful --183-- scheduler: using generic scheduler lock implementation.  --183-- redir: 0x401a641 (ld-linux-armhf.so.3:strlen) redirected 0x3804b240 (???) --183-- redir: 0x401b140 (ld-linux-armhf.so.3:memcpy) redirected 0x3804b26c (???) --183-- redir: 0x401a091 (ld-linux-armhf.so.3:strcmp) redirected 0x3804b378 (???) ==183== conditional jump or move depends on uninitialised value(s) ==183==    @ 0x401a024: index (in /lib/ld-2.23.so) ==183==  uninitialised value created stack allocation ==183==    @ 0x400849c: _dl_init_paths (in /lib/ld-2.23.so) ==183==  ==183== conditional jump or move depends on uninitialised value(s) ==183==    @ 0x401a028: index (in /lib/ld-2.23.so) ==183==  uninitialised value created stack allocation ==183==    @ 0x400849c: _dl_init_paths (in /lib/ld-2.23.so) ==183==  ==183== conditional jump or move depends on uninitialised value(s) ==183==    @ 0x4007e30: expand_dynamic_string_token (in /lib/ld-2.23.so) ==183==  uninitialised value created stack allocation ==183==    @ 0x400849c: _dl_init_paths (in /lib/ld-2.23.so) ==183==  --183-- reading syms /usr/lib/valgrind/vgpreload_core-arm-linux.so --183--    object doesn't have symbol table --183-- reading syms /usr/lib/valgrind/vgpreload_memcheck-arm-linux.so --183--    object doesn't have symbol table --183-- reading syms /root/opencl_arm32_rte/host/arm32/lib/libacl_emulator_kernel_rt.so --183-- reading syms /root/opencl_arm32_rte/host/arm32/lib/libalteracl.so --183--   reading exidx entries: 800 available --183--   reading exidx entries: 668 attempted, 437 successful --183-- reading syms /root/opencl_arm32_rte/host/arm32/lib/libalterammdpcie.so --183--   reading exidx entries: 201 available ==183==   warning: whilst reading exidx: implausible exidx last entry size 5755; using 1 instead. --183--   reading exidx entries: 149 attempted, 80 successful --183-- reading syms /usr/lib/libstdc++.so.6.0.20 --183--    object doesn't have symbol table --183--   reading exidx entries: 1352 available ==183==   warning: whilst reading exidx: extabentryextract: bytecode can't represented --183--   reading exidx entries: 1010 attempted, 546 successful --183-- reading syms /root/opencl_arm32_rte/host/arm32/lib/libelf.so.0 --183-- reading syms /lib/libpthread-2.23.so --183--   reading exidx entries: 121 available ==183==   warning: whilst reading exidx: implausible exidx last entry size 4294967199; using 1 instead. --183--   reading exidx entries: 107 attempted, 107 successful --183-- reading syms /lib/librt-2.23.so --183--    object doesn't have symbol table --183--   reading exidx entries: 19 available ==183==   warning: whilst reading exidx: extabentryextract: bytecode can't represented --183--   reading exidx entries: 14 attempted, 13 successful --183-- reading syms /lib/libdl-2.23.so --183--    object doesn't have symbol table --183-- reading syms /lib/libm-2.23.so --183--    object doesn't have symbol table --183-- reading syms /lib/libgcc_s.so.1 --183--    object doesn't have symbol table --183--   reading exidx entries: 35 available --183--   reading exidx entries: 22 attempted, 22 successful --183-- reading syms /lib/libc-2.23.so --183--    object doesn't have symbol table --183--   reading exidx entries: 650 available ==183==   warning: whilst reading exidx: extabentrydecode: failed error code: -10  ==183==   warning: whilst reading exidx: implausible exidx last entry size 4294964079; using 1 instead. --183--   reading exidx entries: 564 attempted, 452 successful ==183== 4 errors in context 7 of 13: ==183== invalid read of size 4 ==183==    @ 0x56a405c: std::string::_rep::_m_grab(std::allocator<char> const&, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.20) ==183==  address 0x5aa0a64 4 bytes before block of size 20 alloc'd ==183==    @ 0x484625c: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==183==  ==183==  ==183== 4 errors in context 8 of 13: ==183== syscall param write(buf) points uninitialised byte(s) ==183==    @ 0x56f0228: write (in /lib/libpthread-2.23.so) ==183==    0x4e024db: acl_pcie_mm_io_device::write_block(unsigned int, unsigned int, void*) (in /root/opencl_arm32_rte/host/arm32/lib/libalterammdpcie.so) ==183==  address 0x7dc58004 on thread 1's stack ==183==  uninitialised value created stack allocation ==183==    @ 0x4e0245e: acl_pcie_mm_io_device::write_block(unsigned int, unsigned int, void*) (in /root/opencl_arm32_rte/host/arm32/lib/libalterammdpcie.so) ==183==  ==183==  ==183== 7 errors in context 9 of 13: ==183== invalid read of size 4 ==183==    @ 0x56a2f94: std::string::compare(char const*) const (in /usr/lib/libstdc++.so.6.0.20) ==183==  address 0x5aa0a5c 12 bytes before block of size 20 alloc'd ==183==    @ 0x484625c: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==183==  ==183==  ==183== 10 errors in context 10 of 13: ==183== invalid write of size 4 ==183==    @ 0x56a3260: std::string::_rep::_m_dispose(std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.20) ==183==  address 0x5aa0a64 4 bytes before block of size 20 alloc'd ==183==    @ 0x484625c: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==183==  ==183==  ==183== 10 errors in context 11 of 13: ==183== invalid read of size 4 ==183==    @ 0x56a3258: std::string::_rep::_m_dispose(std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.20) ==183==  address 0x5aa0a64 4 bytes before block of size 20 alloc'd ==183==    @ 0x484625c: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==183==  ==183==  ==183== 11 errors in context 12 of 13: ==183== invalid write of size 4 ==183==    @ 0x56a3b70: std::string::_rep::_m_refcopy() (in /usr/lib/libstdc++.so.6.0.20) ==183==  address 0x5aa0a64 4 bytes before block of size 20 alloc'd ==183==    @ 0x484625c: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==183==  ==183==  ==183== 11 errors in context 13 of 13: ==183== invalid read of size 4 ==183==    @ 0x56a3b68: std::string::_rep::_m_refcopy() (in /usr/lib/libstdc++.so.6.0.20) ==183==  address 0x5aa0a64 4 bytes before block of size 20 alloc'd ==183==    @ 0x484625c: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==183==  ==183== error summary: 63 errors 13 contexts (suppressed: 0 0) 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -