[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 'Segmentation fault' in example program
From: |
Neil Jerram |
Subject: |
Re: 'Segmentation fault' in example program |
Date: |
Tue, 09 May 2006 23:10:44 +0100 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Frithjof <address@hidden> writes:
> Hey,
> when trying to compile the example from chapter "2.3.3 Linking
> Guile into Programms" in the Reference Manual with gcc 3.3.5 I get the
> following:
>
> gcc -o simple-guile simple-guile.c -lguile -pthread \
> -Wl,-rpath,/usr/local/lib
>
> (gdb) run
> Starting program: /home/frithjof/krams/guile/simple-guile
> [Thread debugging using libthread_db enabled]
> [New Thread 1076640096 (LWP 3660)]
> [New Thread 1087372208 (LWP 3663)]
> guile> (* 3 3)
> 9
> guile> (version)
> "1.8.0"
> guile> (my-hostname)
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1076640096 (LWP 3660)]
> 0x40180363 in strlen () from /lib/tls/libc.so.6
> (gdb)
>
> Is my system just not set up correctly or is this a bug in Guile or one in
> the example?
Perhaps the HOSTNAME environment variable is not defined in the shell
where you tried this, and so getenv("HOSTNAME") is NULL?
You might like to try making the code for my-hostname safer, like
this:
static SCM
my_hostname (void)
{
char *val = getenv ("HOSTNAME");
return (val ? scm_str2string (val) : SCM_BOOL_F);
}
Regards,
Neil