unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Neil Jerram <neil@ossau.uklinux.net>
Cc: bug-guile@gnu.org
Subject: Re: 'Segmentation fault' in example program
Date: Tue, 09 May 2006 23:10:44 +0100	[thread overview]
Message-ID: <871wv2n923.fsf@ossau.uklinux.net> (raw)
In-Reply-To: <E1FdX5h-0001EI-2X@frithjof.familie> (frithjof@minet.uni-jena.de's message of "Tue, 09 May 2006 20:37:49 +0200")

Frithjof <frithjof@minet.uni-jena.de> 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



_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


  reply	other threads:[~2006-05-09 22:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-09 18:37 'Segmentation fault' in example program Frithjof
2006-05-09 22:10 ` Neil Jerram [this message]
2006-05-09 22:28   ` Marius Vollmer
2006-05-09 22:42 ` Kevin Ryde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871wv2n923.fsf@ossau.uklinux.net \
    --to=neil@ossau.uklinux.net \
    --cc=bug-guile@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).