LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Segmentation Fault (https://www.linuxquestions.org/questions/linux-newbie-8/segmentation-fault-4175670121/)

prakashkjaya 02-23-2020 11:28 AM

Segmentation Fault
 
HI
I am facing Segmentation Fault while installing google chrome pl some help me out

vtel57 02-23-2020 12:12 PM

Need:

- your operating system - which Linux, what version, etc.
- how did you install G. Chrome on the system? Downloaded from your distribution's repos? Or other method?
- start your Google Chrome from a Terminal and COPY/PASTE the output errors here for us.

These items would be helpful to us while trying to troubleshoot your issue.

Standing by...

Mike_Walsh 02-23-2020 12:36 PM

Quote:

Originally Posted by vtel57 (Post 6093357)
- start your Google Chrome from a Terminal and COPY/PASTE the output errors here for us.

Agree with this. Many folks moan about how 'noisy' the Chromium-based browsers are in the terminal, but the browser runs a continuous, on-going 'debugging' session all the time it's operational. That being the case, this is the very best output we can have for helping with this kind of issue....


Mike. ;)

jsbjsb001 02-26-2020 07:12 AM

Quote:

Originally Posted by prakashkjaya (Post 6093347)
HI
I am facing Segmentation Fault while installing google chrome pl some help me out

I doubt it. How would Google chrome be segfaulting while you're installing it (before it's actually installed) ?

Either you're installing it via an installer and NOT from software packages, and therefore it's installer program is segfaulting, or you already have installed it and Google Chrome itself is segfaulting.

Either way, it would indicate a problem in the code of either it's installer program (if you were NOT installing it from software packages), or and probably more likely, the code of Google Chrome itself. Either way, unless you know about programming, then it's unlikely there's anything you can do. And it's equally unlikely that anybody here is going to be able to find out exactly where the problem is in the relevant code, and then create a patch for you.

You should also lookup what a "Segmentation Fault" is, as you'll find it means that a program has attempted to access a part of memory that's not a part of that program's own address space. In other words, memory assigned to another program, and NOT to Google Chrome or it's installer program in this case.

The code below is guaranteed to segfault, as the for loop's termination criteria says, "if i is more than or equal to zero, keep running the loop". But the array it's looping through is only 5 elements in size, so once it gets far enough past that, the program below WILL violate it's address space, and therefore cause a segfault.

Of course, as useless as this program would be by itself, and with only the code below, the fix is easy. Just change the loop's condition so it only executes as long as "i" is no more than "5".

Code:

#include <stdio.h>

int main(void) {

    int array[] = { 1, 2, 3, 4, 5 };

    for( int i = 0; i >= 0; ++i) {                   
          printf("array[%i]\n", array[i]);
    }

    return 0;
}

This is what happens if you compile and run the program above:

Code:

...
array[1258303329]
array[1330859599]
array[1147094348]
array[1599296834]
array[1145981271]
array[792549199]
array[1684957527]
array[796096367]
array[1029636145]
array[1701588782]
array[1935635316]
array[1634101093]
array[7629941]
array[1701588782]
array[1935635316]
array[1634101093]
array[7629941]
array[0]
array[0]
Segmentation fault (core dumped)


rtmistler 02-26-2020 12:13 PM

Quote:

Originally Posted by prakashkjaya (Post 6093347)
HI
I am facing Segmentation Fault while installing google chrome pl some help me out

Welcome to LQ prakashkjaya,

I'd say a slight addition to the queries in Post #2 would be to, "COPY/PASTE all output errors here for us", regardless of whatever actions you've taken.

Based on your problem description, with no updates as yet, you've encountered this while installing google chrome.

It would be helpful for you to confirm what you were doing, explain the method you were using to perform it, and for you to show the output you're seeing.

Not just the final error report, but the details leading up to it will be helpful.

murugesan 02-26-2020 06:20 PM

@prakashkjaya

Copied code from jsbjsb001 and compiled the same at Linux system here:
Quote:

$ /usr/bin/gcc -std=c99 -g -Wall ./segmentation-fault-4175670121.c -o ./a.out
$ # Create core file when program obtaining segmentation fault
$ /usr/bin/ls -ltr | /usr/bin/tail -2 | /usr/bin/awk '{ print $NF}'
segmentation-fault-4175670121.c
a.out
$ ulimit -c unlimited
$ ./a.out
array[1]
array[2]
..
..
array[5]
array[32767]
array[0]
..
..
array[0]
array[-382668880]
..
..
array[7632239]
array[0]
array[0]
Segmentation fault (core dumped)
$ /usr/bin/ls -ltr | /usr/bin/tail -3 | /usr/bin/awk '{ print $NF}'
segmentation-fault-4175670121.c
a.out
core.4562
$ /usr/bin/gdb -q ./a.out ./core.4562
Program terminated with signal 11, Segmentation fault.
#0 0x00000000004004dd in main () at ./segmentation-fault-4175670121.c:7
7 printf("array[%i]\n", array[i]);
(gdb) print i
$1 = 2136
(gdb) quit
The size of array you have defined having maximum 5 elements only
array[0] => first element
array[1] => second element
array[2] => third element
array[3] => fourth element
array[4] => fifth and last element
Using for loop you have written:
for( int i = 0; i >= 0; ++i)
This loop being executed from 0 till maximum number of integer.
Quote:

$ /usr/bin/grep "define INT_MAX" /usr/include/limits.h
# define INT_MAX 2147483647
since we are accessing the element of array out of index.
When that memory being accessed used by some other program, current program receive the signal segmentation fault (SIGSEGV)

Quote:

$ kill -l | /usr/bin/grep -w "11)"
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
Hence
Replace:
Quote:

for( int i = 0; i >= 0; ++i)
{
printf("array[%i]\n", array[i]);
}
With:
Quote:

for( int i = 0; sizeof(array)/sizeof(int) > i ; ++i)
{
printf( "array[%i] %d\n", i, array[i]);
}
sizeof(array) => 20 (at Linux, HP-UX, SunOS, AIX. In turboc DOS sizeof array being 10 bytes)
sizeof(int) => 4 bytes (at Linux, HP-UX, SunOS, AIX. In turboc DOS sizeof int being 2 bytes)
Number of elements => 20/4 => 5 (0 to 4)
Quote:

$ /usr/bin/gcc -std=c99 -g -Wall ./segmentation-fault-4175670121.c -o ./a.out
$ ./a.out
array[0] 1
array[1] 2
array[2] 3
array[3] 4
array[4] 5
$
>> I am facing Segmentation Fault while installing google chrome pl some help me out
Hence if you are obtaining core file execute file command:
Quote:

$ /usr/bin/file ./core.4874
core.4874: ELF 64-bit LSB core file AMD x86-64, version 1 (SYSV), SVR4-style, from 'a.out'
Like the same obtain the value of binary which created the core file ?

rtmistler 02-27-2020 05:52 AM

@murugesan,

You are presuming that the OP received a core file. Perhaps they did, but they've only ever made their one post.

I'm not sure you receive a core file unless you have your system or terminal set to allow this, such as using "ulimit -c unlimited"

It's also quite possible they've solved this, or moved on to another browser and therefore have decided that their question is no longer of any purpose for them.

If they choose to update, we'll find out more.


All times are GMT -5. The time now is 03:05 AM.