unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* alloca bug
@ 2006-12-07 17:56 Jon Wilson
  2006-12-07 19:38 ` Kevin Ryde
  2006-12-12 21:44 ` Neil Jerram
  0 siblings, 2 replies; 11+ messages in thread
From: Jon Wilson @ 2006-12-07 17:56 UTC (permalink / raw)


Hi,
So it looks like the blob in libguile/eval.c (lines 40-56) from the 
autoconf manual to define alloca doesn't work on BSD systems.  This is 
in guile 1.8.1.

In the subdirectory libguile:
eval.c includes __scm.h
__scm.h includes scmconfig.h

scmconfig.h seems to only be created while make all is running (try make 
scmconfig after ../configure).  However, on my system, and Gopi's 
FreeBSD system as well, scmconfig.h includes <stdlib.h>.  So, 
indirectly, eval.c includes <stdlib.h>, and does so prior to the 
autoconf alloca blob.  Since <stdlib.h> defines alloca (in some cases), 
the blob redefines alloca.  Is this something we need to fix (by not 
including <stdlib.h> I would suppose) or is it something that we toss 
into the autoconf people's court?

If this message would more properly go on the guile developers mailing 
list, could someone who is a member of that list please forward it for me?
Regards,
Jon


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
  2006-12-07 17:56 alloca bug Jon Wilson
@ 2006-12-07 19:38 ` Kevin Ryde
  2006-12-11 15:58   ` Jon Wilson
                     ` (2 more replies)
  2006-12-12 21:44 ` Neil Jerram
  1 sibling, 3 replies; 11+ messages in thread
From: Kevin Ryde @ 2006-12-07 19:38 UTC (permalink / raw)
  Cc: guile-user

Jon Wilson <j85wilson@fastmail.fm> writes:
>
> scmconfig.h seems to only be created while make all is running (try
> make scmconfig after ../configure).

Yes, it's generated.

> However, on my system, and Gopi's
> FreeBSD system as well, scmconfig.h includes <stdlib.h>.  So,
> indirectly, eval.c includes <stdlib.h>, and does so prior to the
> autoconf alloca blob.  Since <stdlib.h> defines alloca (in some
> cases), the blob redefines alloca.  Is this something we need to fix
> (by not including <stdlib.h> I would suppose) or is it something that
> we toss into the autoconf people's court?

Assuming we're using the blob correctly then it's an autoconf problem.

Is the blob supposed to come before including <stdlib.h>?  Though that
sounds too easy to mess up, you'd hope the blob could be made to cope
with being after.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
  2006-12-07 19:38 ` Kevin Ryde
@ 2006-12-11 15:58   ` Jon Wilson
  2006-12-11 15:59   ` Jon Wilson
       [not found]   ` <45788ABD.8020901@fastmail.fm>
  2 siblings, 0 replies; 11+ messages in thread
From: Jon Wilson @ 2006-12-11 15:58 UTC (permalink / raw)


Hi,
I'm still trying to get a shell account on my friend's FreeBSD machine.  
Once I've got that, it shouldn't take very long to file a bug report.
Regards,
Jon


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
  2006-12-07 19:38 ` Kevin Ryde
  2006-12-11 15:58   ` Jon Wilson
@ 2006-12-11 15:59   ` Jon Wilson
       [not found]   ` <45788ABD.8020901@fastmail.fm>
  2 siblings, 0 replies; 11+ messages in thread
From: Jon Wilson @ 2006-12-11 15:59 UTC (permalink / raw)


Whoops I sent this email just to Kevin instead of the list...  sorry folks.

Hi Kevin,
> Assuming we're using the blob correctly then it's an autoconf problem.
>
> Is the blob supposed to come before including <stdlib.h>?  Though that
> sounds too easy to mess up, you'd hope the blob could be made to cope
> with being after.
>   

What I'm thinking is that perhaps there is a needed blob for using
stdlib?  I haven't been able to find any such thing, however, with a
cursory bit of googling.  I'm thinking that it is most likely as you say
an autoconf problem.  Who wants to file a bug report?  I don't mind
doing so myself, but I suspect that it is best done by one of our
developers.
Regards,
Jon



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
       [not found]   ` <45788ABD.8020901@fastmail.fm>
@ 2006-12-11 16:00     ` Jon Wilson
  0 siblings, 0 replies; 11+ messages in thread
From: Jon Wilson @ 2006-12-11 16:00 UTC (permalink / raw)


And here was Kevin's reply:

> What I'm thinking is that perhaps there is a needed blob for using
> stdlib?

Perhaps, though the previous version from autoconf didn't.  What it
did used to have though was a wrapping #ifndef,

#ifndef alloca
# ifdef __GNUC__
#  define alloca __builtin_alloca
# else
#  ifdef __DECC
#   define alloca(x) __ALLOCA(x)
#  else
#   ifdef _MSC_VER
#    include <malloc.h>
#    define alloca _alloca
#   else
#    if HAVE_ALLOCA_H
#     include <alloca.h>
#    else
#     if defined (_AIX) || defined (_IBMR2)
....

> Who wants to file a bug report?  I don't
> mind doing so myself, but I suspect that it is best done by one of our
> developers.

Can you put together a minimal failing .c file?  Perhaps what's below
is enough.  I don't have a fleebsd system handy to try.  You can send
it to bug-autoconf saying this has arisen in guile.  Cc guile-devel if
you like.  (You can subscribe to guile-devel but turn off delivery if
you want to post without wanting to read the list.  Nothing exciting
happens on that list anyway. :-)


#include <stdlib.h>

/* This blob per the Autoconf manual (under "Particular Functions"). */
#if HAVE_ALLOCA_H
# include <alloca.h>
#elif defined __GNUC__
# define alloca __builtin_alloca
#elif defined _AIX
# define alloca __alloca
#elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
#else
# include <stddef.h>
# ifdef  __cplusplus
extern "C"
# endif
void *alloca (size_t);
#endif


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
  2006-12-07 17:56 alloca bug Jon Wilson
  2006-12-07 19:38 ` Kevin Ryde
@ 2006-12-12 21:44 ` Neil Jerram
  2006-12-12 21:55   ` Jon Wilson
  1 sibling, 1 reply; 11+ messages in thread
From: Neil Jerram @ 2006-12-12 21:44 UTC (permalink / raw)
  Cc: Guile Users

Jon Wilson <j85wilson@fastmail.fm> writes:

> Hi,
> So it looks like the blob in libguile/eval.c (lines 40-56) from the
> autoconf manual to define alloca doesn't work on BSD systems.  This is
> in guile 1.8.1.

One thing to be aware of is that the so-called "portable"
implementation of alloca() in alloca.c just doesn't work with Guile,
because it doesn't really allocate memory on the stack.

In fact, alloca.c was removed for this reason in 2004:

2004-09-08  Marius Vollmer  <marius.vollmer@uni-dortmund.de>

	* Makefile.am (EXTRA_libguile_la_SOURCES): Removed "alloca.c".

Does anyone know what caused it to reappear?  ChangeLog doesn't reveal
anything.

Guile fundamentally requires a real alloca, which means it has to be a
compiler builtin.

Regards,
     Neil



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
  2006-12-12 21:44 ` Neil Jerram
@ 2006-12-12 21:55   ` Jon Wilson
  2006-12-12 23:24     ` Kevin Ryde
  2006-12-31 11:23     ` Neil Jerram
  0 siblings, 2 replies; 11+ messages in thread
From: Jon Wilson @ 2006-12-12 21:55 UTC (permalink / raw)
  Cc: Guile Users

Hi Neil,

Neil Jerram wrote:
> One thing to be aware of is that the so-called "portable"
> implementation of alloca() in alloca.c just doesn't work with Guile,
> because it doesn't really allocate memory on the stack.
>   
alloca.c from where?  From libc?  If so, which libc?  Or do you mean 
some file alloca.c within the guile source?
> In fact, alloca.c was removed for this reason in 2004:
>
> 2004-09-08  Marius Vollmer  <marius.vollmer@uni-dortmund.de>
>
> 	* Makefile.am (EXTRA_libguile_la_SOURCES): Removed "alloca.c".
>
> Does anyone know what caused it to reappear?  ChangeLog doesn't reveal
> anything.
>   
I don't see any file called alloca.c in the 1.8.1 source tree.
> Guile fundamentally requires a real alloca, which means it has to be a
> compiler builtin.

I'm puzzled now.  Could you please clarify exactly what you are talking 
about?

What I was referring to was the fact that when you #include stdlib.h on 
a BSD system, and then use autoconf's blob of code to define alloca, 
using the BSD default libc and cc, you get a preprocessor error that 
says that alloca has already been defined.  Or, at the least, guile's 
libguile/eval.c does #include stdlib.h, and does use autoconf's blob, 
and produces such an error.  The location of the previous definition is 
given as stdlib.h.  Are we talking about the same thing?  If so, I need 
some help understanding what you've said.
Regards,
Jon


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
  2006-12-12 21:55   ` Jon Wilson
@ 2006-12-12 23:24     ` Kevin Ryde
  2006-12-13  5:12       ` Jon Wilson
  2006-12-31 11:23     ` Neil Jerram
  1 sibling, 1 reply; 11+ messages in thread
From: Kevin Ryde @ 2006-12-12 23:24 UTC (permalink / raw)
  Cc: guile-user

Jon Wilson <j85wilson@fastmail.fm> writes:
>
> I need some help understanding what you've said.

AC_FUNC_ALLOCA in configure normally uses an alloca.c
(libguile/alloca.c) to provide alloca() if the compiler or C library
doesn't otherwise have one.  Should be unrelated to whatever happens
on bsd.

Not sure why libguile/alloca.c has to exist.  Does autoconf insist on
it being present, even if we then reject that version?


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
  2006-12-12 23:24     ` Kevin Ryde
@ 2006-12-13  5:12       ` Jon Wilson
  0 siblings, 0 replies; 11+ messages in thread
From: Jon Wilson @ 2006-12-13  5:12 UTC (permalink / raw)


Hi Kevin,

Kevin Ryde wrote:
> Jon Wilson <j85wilson@fastmail.fm> writes:
>   
>> I need some help understanding what you've said.
>>     
>
> AC_FUNC_ALLOCA in configure normally uses an alloca.c
> (libguile/alloca.c) to provide alloca() if the compiler or C library
> doesn't otherwise have one.  Should be unrelated to whatever happens
> on bsd.
>
> Not sure why libguile/alloca.c has to exist.  Does autoconf insist on
> it being present, even if we then reject that version?
>   

Thanks.  Now I get what Neil was talking about.  I've got that shell 
account now, but it is getting late.  I'll take a look at making a bug 
report tomorrow.  Plenty of time now classes are all over, and all I 
have left are grad school apps.  Speaking of which, if anyone is at Ohio 
State and could put in a good word for me with the physics department, 
that would be favorite.</shameless plug>
Regards,
Jon


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
  2006-12-12 21:55   ` Jon Wilson
  2006-12-12 23:24     ` Kevin Ryde
@ 2006-12-31 11:23     ` Neil Jerram
  2007-01-01 22:22       ` Kevin Ryde
  1 sibling, 1 reply; 11+ messages in thread
From: Neil Jerram @ 2006-12-31 11:23 UTC (permalink / raw)
  Cc: Guile Users

Jon Wilson <j85wilson@fastmail.fm> writes:

> alloca.c from where?  From libc?  If so, which libc?  Or do you mean
> some file alloca.c within the guile source?

Yes, there's a libguile/alloca.c in Guile CVS.  It probably doesn't
survive into any distributions though (and shouldn't).

> I'm puzzled now.  Could you please clarify exactly what you are
> talking about?

After reviewing the thread again, I think my interjection was a red
herring - sorry.

I noticed that libguile/alloca.c was still around, when I thought it
had been removed, and got worried about that.  In fact I don't think
it can ever get built in, so it can't do any harm.

> What I was referring to was the fact that when you #include stdlib.h
> on a BSD system, and then use autoconf's blob of code to define
> alloca, using the BSD default libc and cc, you get a preprocessor
> error that says that alloca has already been defined.  Or, at the
> least, guile's libguile/eval.c does #include stdlib.h, and does use
> autoconf's blob, and produces such an error.  The location of the
> previous definition is given as stdlib.h.  Are we talking about the
> same thing?  If so, I need some help understanding what you've said.

Thanks, I understand now.  Agree that this is a bug with the autoconf
blob for BSD.  Has anyone reported it yet?

In the meantime, can we fix this for guile by just adding #ifndef
alloca around the whole blob?  Would that have bad effects on other
OSs?

Regards,
     Neil



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: alloca bug
  2006-12-31 11:23     ` Neil Jerram
@ 2007-01-01 22:22       ` Kevin Ryde
  0 siblings, 0 replies; 11+ messages in thread
From: Kevin Ryde @ 2007-01-01 22:22 UTC (permalink / raw)
  Cc: guile-user

Neil Jerram <neil@ossau.uklinux.net> writes:
>
> In the meantime, can we fix this for guile by just adding #ifndef
> alloca around the whole blob?  Would that have bad effects on other
> OSs?

Sounds good.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-01-01 22:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-07 17:56 alloca bug Jon Wilson
2006-12-07 19:38 ` Kevin Ryde
2006-12-11 15:58   ` Jon Wilson
2006-12-11 15:59   ` Jon Wilson
     [not found]   ` <45788ABD.8020901@fastmail.fm>
2006-12-11 16:00     ` Jon Wilson
2006-12-12 21:44 ` Neil Jerram
2006-12-12 21:55   ` Jon Wilson
2006-12-12 23:24     ` Kevin Ryde
2006-12-13  5:12       ` Jon Wilson
2006-12-31 11:23     ` Neil Jerram
2007-01-01 22:22       ` Kevin Ryde

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).