NetBeans gives segfault, running the prgram using terminal does not

1k views Asked by At

I am confronted to a very weird problem. When running my very simple one file program via NetBeans, I have the following error:

RUN FINISHED; Segmentation fault; core dumped; real time: 150ms; user: 0ms; system: 0ms

My run command is simple ./Name-Of-The-File.

When I use a terminal and cd to the folder containing the program and run the same command, I get the following output:

Hullo
PLatform Number is : 1
Hullo

(Note that the Hullos were added to pinpoint where the segfault happened, as my very first line in main() prints Hullo.)

Here is the code of the program:

/* 
 * File:   main.cpp
 * Author: sysgen
 *
 * Created on June 4, 2015, 7:08 PM
 */

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <CL/cl.hpp>

const std::string hw("Hello World \n");

/*
 * 
 */

//OpenCL Error checking function

inline void checkErr(cl_int err, const char *name){
    if (err != CL_SUCCESS){
        std::cerr << "FATAL OPENCL ERROR: " << name << "( " << err << ") " << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main(void) {
    //Creating an OpenCL context

    std::cout << "Hullo" << std::endl;

    cl_int err;
    std::vector< cl::Platform > platformList; //We make a vector which will contain the platforms
    cl::Platform::get(&platformList);
    checkErr(platformList.size() !=0 ? CL_SUCCESS : -1, "cl::Platform::get");
    std::cerr << "PLatform Number is : " << platformList.size() << std::endl;
    std::string platformVendor;
    platformList[0].getInfo((cl_platform_info)CL_PLATFORM_VENDOR, &platformVendor);

    std::cout << "Hullo" << std::endl;

    return 0;
}

This error also manifests in codeblocks. There is more details produced by gdb:

Building to ensure sources are up-to-date
Selecting target: 
Debug
Adding source dir: /home/sysgen/NetBeansProjects/OpenCL SVOGL/
Adding source dir: /home/sysgen/NetBeansProjects/OpenCL SVOGL/
Adding file: /home/sysgen/NetBeansProjects/OpenCL SVOGL/bin/Debug/OpenCL SVOGL
Changing directory to: "/home/sysgen/NetBeansProjects/OpenCL SVOGL/."
Set variable: LD_LIBRARY_PATH=.:/opt/AMDAPPSDK-3.0-0-Beta/lib/x86_64/:/usr/lib32
Starting debugger: /usr/bin/gdb -nx -fullname  -quiet  -args "/home/sysgen/NetBeansProjects/OpenCL SVOGL/bin/Debug/OpenCL SVOGL"
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Reading symbols from /home/sysgen/NetBeansProjects/OpenCL SVOGL/bin/Debug/OpenCL SVOGL...(no debugging symbols found)...done.
Debugger name and version: GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9
Program received signal SIGSEGV, Segmentation fault.
In ?? () ()
177 dlerror.c: No such file or directory.
#1  0x00007ffff70dd6fd in init () at dlerror.c:177
0

There are 0 answers