Hi Artyom,

Artyom Poptsov <poptsov.art...@gmail.com> skribis:

> thanks for pointing that out.  IIRC, I saw this kind of errors during
> testing but I thought I fixed them.  What Guile-SSH version do you use?

I just realized I was still using 0.9.0, sorry for the confusion!

> Here's 'free_session' procedure from Guile-SSH version 0.10.0:
>
> size_t
> free_session (SCM session_smob)
> {
>   if (! SCM_SMOB_PREDICATE (session_tag, session_smob))
>     {
>       _ssh_log (SSH_LOG_FUNCTIONS, "free_session", "%s", "already freed");
>       return 0;
>     }

I think this is incorrect.  AIUI, with 2.0.12, the SMOB type predicate
is always false, so you end up never freeing anything; see smob.c:

--8<---------------cut here---------------start------------->8---
static void
finalize_smob (void *ptr, void *data)
{
  SCM smob;
  scm_t_bits smobnum;
  size_t (* free_smob) (SCM);

  smob = PTR2SCM (ptr);
  smobnum = (scm_t_bits) GC_call_with_alloc_lock (clear_smobnum, ptr);

#if 0
  printf ("finalizing SMOB %p (smobnum: %u)\n", ptr, smobnum);
#endif

  free_smob = scm_smobs[smobnum].free;
  if (free_smob)
    free_smob (smob);
}
--8<---------------cut here---------------end--------------->8---

Here ‘clear_smobnum’ is the procedure that changes PTR to have the
“finalized smob” type.

So the right thing would be to replace:

  struct session_data *data = _scm_to_session_data (session_smob);

… with:

  struct session_data *data = SCM_SMOB_DATA (session_smob);

Does it make sense?

Thanks,
Ludo’.

Reply via email to