Open GoogleCodeExporter opened 9 years ago
I can't reproduce this on SBCL win32/1.0.29. I'll download 1.0.32 and try it
out. Some
comments;
#1 - A carriage return in the Window :title-caption is never good.
#2 - Anything in :IDLE is called once per frame. The default frame-rate is
30fps. This
means that (sb-ext:run-program "/bin/bash" (list "-c" "ls")) is being run 30
times per
second!
Original comment by Clruok...@gmail.com
on 17 Jan 2010 at 3:20
[deleted comment]
"putenv" takes a string of the form NAME=VALUE, which is what is passed into
the
foreign function. int putenv(char *string);
"setenv" does not match the foreign function definition so I'm not sure why
this would
work. I would expect this to cause an immediate visit to the debugger.
Original comment by Clruok...@gmail.com
on 17 Jan 2010 at 3:43
Original comment by Clruok...@gmail.com
on 17 Jan 2010 at 6:34
This is over my head, and i don't really understand the issue.
#1 I'm sorry, i don't even know what a carriage return is.
#2 Wait is set true by defaul, so run-programm shoud waits the call is finished
And this doesn't seem to be the problem, since it's also accours if it's called
only once at the beginning.
I really don't know, but a Faré in the above link states:
Note that setenv and unsetenv seem to be better interfaces to provide than
putenv,
and do the malloc'ing for you.
Thank you for caring, but i'm fine as long as it works for me.
Original comment by stoned-j...@gmx.net
on 17 Jan 2010 at 3:07
Carriage return is the newline in :title-caption between "without setting the
title
caption," and "the error pops up from the first start". This should be;
:title-caption "without setting the title caption, the error pops up from the
first
start"
Original comment by Clruok...@gmail.com
on 17 Jan 2010 at 3:49
Ah OK, I didn't realize that sb-ext:run-program was a synchronous call.
I still don't understand how renaming 'putenv' to 'setenv' works for you.
Because now
the code will be making the following call...
(setenv <string>)
...when in fact the correct API is for 'setenv' should be
(setenv <string> <string> <int>)
I agree that setenv is the better call to use though.
Original comment by Clruok...@gmail.com
on 17 Jan 2010 at 3:57
Hey, this still hasn't been fixed and it's been a year.
In fact, this problem has broader scope than an obscure error in SBCL on Linux.
It happens on Macs, too, and it's caused by _anything_ that sets up an SDL
display surface. Such as, for example, the "mandelbrot" demonstration program
in lispbuilder-sdl-examples. Try it, run "(sdl-examples:mandelbrot)" a few
times and then call run-program on anything; likely you will get a
c-string-decoding-error.
I ran into this problem when attempting to write a game. It was pretty
irritating in itself (I like accessing the clipboard), but more seriously, it
led me to think (as a hopeful newcomer to lispbuilder-sdl) that this library
wasn't well-supported on Macs, or on SBCL, or that SBCL wasn't well-supported
on Macs, or something--whatever the reason, I shouldn't be surprised if
everything else is also subtly broken, and if I want to write my cross-platform
Lisp game I should look elsewhere. Only my failure to find acceptable
alternatives led me to come back here and try to fix this stuff. (And lo and
behold, it turns out that it's a simple misuse of "putenv".) I think this is
pretty bad and it should be fixed (Priority-Low, my invalid argument to
putenv!).
Quick fix: Replace the definition of "sdl-put-env" in
lispbuilder-sdl/cffi/stdinc.lisp with this:
(defun sdl-put-env (string)
#-sbcl
(cond
((cffi:foreign-symbol-pointer "SDL_putenv" :library 'sdl)
(cffi:foreign-funcall-pointer (cffi:foreign-symbol-pointer "SDL_putenv") () :string string :int))
((cffi:foreign-symbol-pointer "putenv")
(cffi:foreign-funcall-pointer (cffi:foreign-symbol-pointer "putenv") () :string string :int)))
#+sbcl
(let ((p (position #\= string)) ;taken from sbcl-1.0.47/contrib/sb-posix/interface.lisp
(n (length string)))
(if p
(if (= p n)
(sb-posix:unsetenv (subseq string 0 p))
(sb-posix:setenv (subseq string 0 p) (subseq string (1+ p)) 1))
(error "Invalid argument to putenv: ~S" string))))
It works perfectly now, as far as I can tell.
Future fix: Ideally you wouldn't need platform-specific code there. Does
"putenv" (as opposed to "setenv") work on other Lisp implementations? If so,
perhaps it could be considered a problem with SBCL, and they might fix it. Or
the CFFI library might provide a unified "putenv" function (they already have
platform-specific code). Or lispbuilder-sdl could just switch over to "setenv"
for all implementations (probably using CFFI to call it).
I suspect this last solution is both easiest and best. I get the impression
that the only drawback of setenv is that it allocates memory (copying the env
string), and that conceivably the GC might not know how to free it (?), but
that even if that happens it's unlikely to be a problem, because a program is
likely to use setenv only a couple of times during startup and not in the main
program. (In this case, it's used by "set-video-driver", "set-audio-driver",
and "set-window-position".)
Original comment by JohntheS...@gmail.com
on 22 Apr 2011 at 5:17
The GC not knowing how to free memory is a problem. It may decide to free the
object minutes into the game, and crash suddenly and unexpectedly. Very hard to
debug.
I want to play around with SBCL some more to see what's up. Thanks for the
feedback.
Original comment by Clruok...@gmail.com
on 24 Apr 2011 at 5:11
Original issue reported on code.google.com by
stoned-j...@gmx.net
on 15 Jan 2010 at 4:44