Thread: Function call problem (segmentation fault)

  1. #1
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    103

    Function call problem (segmentation fault)

    Hello,

    Considering this project:

    I try to call a function in benchmark.c file. The existing calls work well in search.c file. But my newer call causes segmentation fault. I suspect there can be some sort of initializing code. I tried various ideas, none worked. part of code:

    benchmark.c:

    Code:
    void benchmark(Position *current, char *str)
    {
        [CODE BEFORE]
    
        strcpy(buf, "fen ");
        strncat(buf, fens[i], 127 - 4);
        buf[127] = 0;
    
    
        position(&pos, buf);
        //evaluate(&pos); // causes problems, from evaluate.h
        
        [CODE AFTER]
    }
    Can you help me correctly call this function ?

  2. #2
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    804
    Not enough information to know what "Position" is.

    We don't know the size of str, buf, or fens, or what they contain.

    You need to provide a small complete program so we can compile and test, and know what all the variables are.

    We should not have to download many files from a complex program on another site to answer your question.
    Last edited by rstanley; 03-25-2021 at 11:59 AM.

  3. #3
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    103
    I have no idea on how to produce a simple code based on the original one. I may ask the question on a place , where some may know the project's internals. Thanks anyway.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. segmentation fault at free() call
    By mrityunjay23 in forum C Programming
    Replies: 4
    Last Post: 07-08-2014, 11:14 PM
  2. Segmentation fault in call to recursive function
    By tarajano in forum C Programming
    Replies: 4
    Last Post: 04-13-2014, 12:27 PM
  3. Replies: 3
    Last Post: 11-05-2012, 04:21 PM
  4. seg fault with any function call
    By LegoMan in forum C Programming
    Replies: 5
    Last Post: 04-15-2009, 05:30 PM
  5. Problem with a function ("Segmentation fault")
    By kinghajj in forum C Programming
    Replies: 6
    Last Post: 02-21-2004, 01:31 PM

Tags for this Thread