SIGSEGV, segmentaition fail

Can you help with this error? This happens after build, when I debug:

GCC Block code

K just linked refu.dll library, which contains timer function.

This is what I see on screen:
http://oi59.tinypic.com/2zgte1e.jpg

This is main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "include/types.h"
#include "include/gaussian.h"
#include "include/args.h"
#include "refu/Time/rfc_timer.h"
#include <stdbool.h>


int main ( int argc, char *argv[] )
{
    uint32_t gaussianSize;
    float gaussianSigma;
    char* imgname;//the name of the image file, taken by the arguments

    /** TIMER STUFF **/
    char errorLog[] = "errorLog";
    char infoLog[] = "infoLog";
    double units;
    //init the Refu library
    rfInit(errorLog,infoLog);


    //read in the program's arguments
    if(readArguments(argc,argv,&imgname,&gaussianSize,&gaussianSigma)==false)
        return -1;

    RF_Timer timer;
    rfTimer_Init(&timer,RF_TIMER_MICROSECONDS);
    /** perform CPU blurring *//
    if(pna_blur_cpu(imgname,gaussianSize,gaussianSigma)==false)//time it
        return -2;
    units = rfTimer_Query(&timer,RF_TIMER_MICROSECONDS);
    printf("CPU Gaussian blurring took %f microseconds\n",units);

    //reset the timer for the GPU
    rfTimer_Query(&timer,RF_TIMER_MICROSECONDS);

    //perform GPU blurring and then read the timer
    if(pna_blur_gpu(imgname,gaussianSize,gaussianSigma)==false)
        return -3;
    units = rfTimer_Query(&timer,RF_TIMER_MICROSECONDS);//time it
    printf("GPU Gaussian blurring took %f microseconds\n",units);

    return 0;
}


Project can be downloaded here, included the refu library:
http://sourceforge.net/projects/autots/files/Gaussian_with_OpenCL%202.zip/download


Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: W:\___NEW_PROJECTS\GaussianBlur\Gaussian_with_OpenCL 1\
Adding source dir: W:\___NEW_PROJECTS\GaussianBlur\Gaussian_with_OpenCL 1\
Adding file: W:\___NEW_PROJECTS\GaussianBlur\Gaussian_with_OpenCL 1\bin\Debug\Gaussian_with_OpenCL.exe
Changing directory to: W:/___NEW~1/GAUSSI~1/GAUSSI~2/.
Starting debugger: P:\CodeBlocks_32bit\MINGW\bin\gdb.exe -nx -fullname -quiet -args W:/___NEW~1/GAUSSI~1/GAUSSI~2/bin/Debug/GAUSSI~1.EXE
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.5
Child process PID: 340
Program received signal SIGSEGV, Segmentation fault.
In ntdll!RtlEnumerateGenericTableLikeADirectory () (C:\WINDOWS\system32\ntdll.dll)
Last edited on
Not taken a deep look, but I suspect the imgname variable, because it has not been initialized, but is being used as an argument.

Aceix.
This is the same:
1
2
3
uint32_t gaussianSize = 0;
float gaussianSigma = 0.0;
char imgname[] = "";//the name of the image file, taken by the arguments 


Recently I run the program without problem, but after I added the refu library and timer this happens. I commented the timers and the problem stays. I commented the refu library and still the same. I removed the link to refu library and still the same.

It says there is some problem In
ntdll!RtlEnumerateGenericTableLikeADirectory () (C:\WINDOWS\system32\ntdll.dll)Debugger finished with status 0

Debugger finished with status 0

Edit:
Even this fails:
1
2
3
4
int main ( int argc, char *argv[] )
{
        return 0;
}

empty project
Last edited on
http://www.cplusplus.com/forum/general/112111/

funny thing, your code does not compile
main.c: In function ‘main’:
main.c:28:32: error: expected expression before ‘/’ token
/** perform CPU blurring *//



> char imgname[] = "";
¿how big is that array?


> It says there is some problem In
perform a backtrace
Assume that the problem is in your code.
Also, run your program through valgrind to check invalid access
I can compiled the program, I can run it but then I run it, there Windows pop up window saying there was error and it must to close the program. I click Don't send the information about the crash and the window disappears; then the program finished. But the console was not closed. The dialog windows has had sad there was problem, but the program did not crash really. And idea what this means?


I have removed that slash and recompiled it but it still does the same error. I returned back to no initiation of the three variables. I don't think it's problem. It was there before and should work.
Last edited on
> I have removed that slash and recompiled it but it still does the same error
That wasn't a solution.
I was complaining that you have provided false information, making us debug a program that didn't even build.

> I returned back to no initiation of the three variables.
> I don't think it's problem.
your `readArguments()' functions is the one that should initialize that variable.
Notice how you are passing the memory address of `imgname' to it.
¿didn't you write that code?
Last edited on
No. But I have restarted code blocks and succeed to compile and run.
Last edited on
what does readArguments(...) do with imgname?

Does it allocate memory for it or (what i think) expect you to provide enough memory? If the latter is the case the program will crash because the buffer you provide is too small.
@coder777
1
2
3
4
5
6
7
8
9
//prototype
char readArguments(int argc,
                   char *argv[],
                   char** imgname,
                   uint32_t* gaussianSize,
                   float* gaussianSigma);

//call
    if(readArguments(argc,argv,&imgname,&gaussianSize,&gaussianSigma)==false)
Notice how he's passing the memory address of `imgname' to it (keep in mind that he's coding in C)


@OP: ¿did you run in debug mode?
Topic archived. No new replies allowed.