Re: with-foreign-object allocation question
"Tim Bradshaw (as tfb at cley dot com)" <[email protected]> Fri, 10 Apr 2026 12:41:08 +0100
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
If LW's alloca is like C's, then presumably the thing is on the stack and is probably 'legal' until something else overwrites it with probably-bad results? --tim > On 10 Apr 2026, at 09:51, Madhu (as enometh at meer dot net) <[email protected]> wrote: > > sorry for the immediate followup: > > actuallythere is a another deeper problem because ARGS may be used > after it is freed, it really should be allocated and not freed, but > that is not the point of failure in other lisps, or on lispworks, > > * In <[email protected]> > I wrote on Fri, 10 Apr 2026 14:08:38 +0530 (IST) > >> I am trying to fix a lethal memory bug in >> https://github.com/StjepanPoljak/musicli src/jack.c: (start-jack-callbacks) >> where there is a call >> >> (cffi:with-foreign-object (args '(:pointer (:struct jack-cb-args))) >> ... clobber 24 bytes == (sizeof (:struct jack-cb-args)) >> allocated at ARGS ...) >> >> which should really read >> >> (cffi:with-foreign-object '(:struct jack-cb-args) ...) >> >> this reliably crashes other lisps, but not lwl 64 personal. what >> could be the reason for this resiliance? macroexpansion on the >> incorrect form shows >> >> (fli:with-dynamic-foreign-objects nil >> (let* ((#:size6844 8) >> (args (fli:alloca :type :byte :nelems #:size6844))) >> >> Which shows only 8 bytes being allocated. but are allocations aligned >> at > 24byte offsets, so the memory corruption doesn't show up in >> lispworks in this case? >> >> -- Madhu >> >> (project author bcc'd) > > _______________________________________________ > Lisp Hug - the mailing list for LispWorks users > [email protected] > http://www.lispworks.com/support/lisp-hug.html _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html