logo
down
shadow

Why C program in whch two functions call each other recursively gives segmentation fault on linux?


Why C program in whch two functions call each other recursively gives segmentation fault on linux?

By : jole
Date : October 19 2020, 06:10 AM
it helps some times Each nested function call consumes some stack space for the arguments and the return address. In your code the nested function calls are unbounded, so they consume an unbounded amount of stack. Once the stack is exhausted, the program goes on to write return addresses outside the memory allocated to the process and crashes.
Depending on the compiler, turning on optimizations might help because of tail call optimization.
code :


Share : facebook icon twitter icon
Ported Qt program (Windows to linux) segmentation fault

Ported Qt program (Windows to linux) segmentation fault


By : kumar
Date : March 29 2020, 07:55 AM
hope this fix your issue I have fixed the issue myself by creating a complete new project and copying every file. As such I think the error must lie within the user file.
everyone for your suggestions !
Getting segmentation fault in Linux when running my C program

Getting segmentation fault in Linux when running my C program


By : LAMP Developer
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Joachim Pileborg's answer is obviously correct, just try to run your program as
code :
./a.out a \> b
Segmentation fault(core dumped) in recursively listing of directories and files in C, Linux

Segmentation fault(core dumped) in recursively listing of directories and files in C, Linux


By : Je Moua
Date : March 29 2020, 07:55 AM
this will help so basically the issue appears when I try to run a function which recursively prints the paths for files and directories. The issue that I am getting in terminal when I run the program is "Segmentation fault (core dumped)". , Observe when you exit the while:
code :
dirent = readdir(dir)) != NULL
if(dirent->d_type == DT_DIR)
while((dirent = readdir(dir)) != NULL){
    if(strcmp(dirent->d_name, ".") != 0 && strcmp(dirent->d_name, "..") != 0){
        sprintf(name, "%s/%s", path, dirent->d_name);
        printf("%s\n", name);
        if(dirent->d_type == DT_DIR){
            list_recursive(name);
        }
    }
}
Segmentation fault while running Java program on Linux

Segmentation fault while running Java program on Linux


By : Christine Merrifield
Date : March 29 2020, 07:55 AM
it helps some times I am running a JAVA program on RHEL 6.4 Server. The program terminates abnormally displaying the messaeg "Segmentation fault(Core dumped)". But i do not find any file indicating the reason for termination in the current user directory from where the program was run. ,
how is segmentation fault possible.
segmentation fault in c program in linux

segmentation fault in c program in linux


By : Mostafa Hasanzadeh
Date : March 29 2020, 07:55 AM
like below fixes the issue From vfork man page
Related Posts Related Posts :
  • Random function stuck on one number
  • printf following zeros to a certain degree
  • Measuring CPU clocks consumed by a process
  • How is a CRC32 checksum calculated?
  • Tips on redefining a register bitfield in C
  • Converting a program from c to bash script
  • Static library not included in resulting LLVM executable
  • What is the meaning of "wild pointer" in C?
  • Reading DWORD from binary file
  • Efficient way to find divisibility
  • Whats the fastest, portable way to hash pointers we know are pointer aligned to a fixed size int?
  • Why does my summation program behaves weird?
  • How to determine values saved on the stack?
  • Thread scheduling C
  • C - converting to 2s complement
  • wireless networks c program
  • From where does the uboot get the information about flash, RTC, RAM in uboot/kernel development
  • printf behaviour in C
  • Measure size and way-order of L1 and L2 caches
  • Efficient copy of entire directory
  • Efficient way to create/unpack large bitfields in C?
  • getnameinfo prototype asks for sockaddr not sockaddr_in?
  • Linked List Sorting with Strings In C
  • Typecasting a floating value or using the math.h floor* functions?
  • Problem implementing sorting algorithm in C with an array of structs
  • How to copy a ram_base file to disk efficiently
  • How to fix casting a pointer to an integer?
  • How to round floating point numbers to the nearest integer in C?
  • PIC C - Sending 200 values over USB, but it only sends 25 or so of them
  • How do you return a string from a function correctly in Dynamic C?
  • Monotonic clock on IRIX
  • setsockopt (sys/socket.h)
  • How to make C program wait (on Linux)?
  • i find a problem using atoi() method in ansi c?
  • Why is this array being initialized in an odd way?
  • How to execute commands in chroot?
  • Microsecond (or one ms) time resolution on an embedded device (Linux Kernel)
  • Question about variable definitions in functions
  • SMTP on C: STARTTLS via OpenSSL
  • fetch value of ipaddress
  • Binary expressions in C
  • Why do char * and char ** have the same value?
  • problem in allocating kernel memory by malloc() from user space?
  • dangling pointer, reason for value change after free()?
  • How to compile C program with multiple files in Xcode
  • Can you make an incrementing compiler constant?
  • Reading data from text file in C
  • SQLite's test code to production code ratio
  • Displaying an inverted pyramid of asterisks
  • sd spi mode in C language
  • printf("%2d") in C programming
  • Add a certain number of bytes to a void pointer in C
  • How should I protect against hard link attacks?
  • What's the difference between unsigned long/long/int in c/c++?
  • Get an input from keyboard without 'return' in C
  • How to convert if to switch-case in c
  • C: swapping two pointer value
  • What does \x mean in c/c++?
  • run a command line argument prog
  • Pass a dynamic structure by reference? [C]
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk