I've seen similar things in lots of code ported to different architectures. Quite a few different gotchas where something you can ignore harmlessly on one system, explodes on another, because something you took for granted has changed.
If you forget to include stdlib.h and math.h, your code may still work in 32-bit. It will assume these undeclared functions take all-integers and fill in the blanks. On a 64-bit system, where pointers are twice as large, that assumption is catastrophically wrong and causes memory addresses to get mangled, causing a crash.
Also, some systems let you do this, but don't depend on it, because most don't:
Code that has problems like that is NOT working, despite your personal point of view. It is undefined behavior. So you understand: undefined behavior means the program is no longer following any rules. It went into lala land. It could limp forward until it hits an exit point, it could format all disks, it could contact the New Horizons spacecraft and order a pizza.
I would say the compiler implementers for the box's C compiler code decided to do some goof-proofing. The limp along option. They likely have a SIGSEGV signal trap? I do not know. If you have a truss equivalent on the box, you can find out if the segmentation fault has been blocked somehow.
I am not trying to be a grumpy old problem monger. But undefined behavior is never "working". Ask Don Cragun or Corona688.
These 3 Users Gave Thanks to jim mcnamara For This Post:
Don't be embarassed! C is very different from most languages. It's a high-level language which writes pure assembly, with all the safety you get from pure assembly...
Hi Guys,
I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error:
"Segmentation fault"
Can someone please help me resolve this?
Thanks alot (2 Replies)
this is a network programming code to run a rock paper scissors in a client and server.
I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault.
-the segmentation fault is fixed
Current problem -Also... (3 Replies)
I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this :
i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
i have this code
int already_there(char *client_names, char *username) {
int i;
for(i = 0; i<NUM; i++) {
printf("HERE\n");
if (strcmp(client_names, username)==0) return(1);
}
return(0);
}
and i get a segmentation fault, whats wrong here? (7 Replies)
I'm getting a segmentation fault. I'm new to Linux programming. Thanks so much for all of your input.:eek:
#include </usr/include/mysql++/mysql++.h>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <string.h>
using namespace std;
int outputToImport(const char*... (1 Reply)
If I do this.
Assume
struct life
{
char *nolife;
}
struct life **life;
// malloc initialization & everything
if(life->nolife == 0)
Would I get error at life->nolife if it is equal to 0.
wrong accession? (3 Replies)
Hi,
on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error :
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
using channel ORA_DISK_1
Segmentation fault
What does it mean ? And the solution ?
Many thanks. (0 Replies)
Hi ,
During execution a backup binary i get following error
"Program error 11 (Segmentation fault), saving core file in '/usr/datatools"
Riyaz (2 Replies)
sometimes for this code i get a segmentation fault for codes llike this
:
int main{
int * a= 0;
int b;
a = (int*)malloc(sizeof(int));
///some code using these variable but no freeing of a
if(a){
free(a);
a = 0;
}
return... (3 Replies)