Groups | Search | Server Info | Login | Register


Groups > comp.os.vms > #378318

Re: more CMA

From cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups comp.os.vms
Subject Re: more CMA
Date 2025-12-05 17:15 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <10gv3v9$4d6$1@reader2.panix.com> (permalink)
References <10gqr6c$3saak$1@dont-email.me> <10gsjum$heon$1@dont-email.me> <10gsmf7$fd7v$2@dont-email.me> <69320352$0$673$14726298@news.sunsite.dk>

Show all headers | View raw


In article <69320352$0$673$14726298@news.sunsite.dk>,
Arne Vajhøj  <arne@vajhoej.dk> wrote:
>On 12/4/2025 2:12 PM, Arne Vajhøj wrote:
>> On 12/4/2025 1:29 PM, Simon Clubley wrote:
>>> On 2025-12-04, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>>
>>>> A sequence of:
>>>>
>>>> cma_thread_create
>>>> cma_mutex_lock
>>>> cma_mutex_unlock
>>>> cma_thread_join
>>>>
>>>> and after a little over 10000 iterations:
>>>>
>>>> %SYSTEM-F-INSFMEM, insufficient dynamic memory
>>>> %TRACE-F-NOMSG, Message number 00098054
>>>> %TRACE-I-NOMSG, Message number 00098043
>>>>
>>>
>>> Resource leak ?
>> 
>> Definitely.
>> 
>> But the code is rather simple.
>> 
>> Shortest reproducer:
>> 
>> #include <stdio.h>
>> #include <stdlib.h>
>> 
>> #include <unistd.h>
>> #include <cma.h>
>> 
>> void *run(void *p)
>> {
>>      if(p != NULL) printf("arg pointer = %p\n", p);
>>      return NULL;
>> }
>> 
>> int main()
>> {
>>      cma_t_thread t;
>>      cma_t_exit_status stat;
>>      void *p;
>>      cma_init();
>>      int n = 0;
>>      while(1)
>>      {
>>          cma_thread_create(&t, &cma_c_null, run, NULL);
>>          cma_thread_join(&t, &stat, &p);
>
>Insert:
>
>cma_thread_detach(&t);
>
>and memory gets freed.
>
>I don't know if this is intentional.

It appears so.  From the extant documentation I could find about
CMA threads, in the description of, `cma_thread_create`:

|The thread object exists until the cma_thread_detach routine is
|called **and** the thread terminates, whichever occurs last.

[Emphasis added; note the "and" there.]

Source: https://alpha-supernova.dev.filibeto.org/lib/rel/4.0B/HTML/AA-Q2DPC-TKT1_html/thrd0321.html#cma_thread_create_46

>Usually join is sufficient.

With pthreads, yes.  Evidently not with CMA.

Why bother with CMA, anyway?  Just use pthreads?

	- Dan C.

Back to comp.os.vms | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-03 21:21 -0500
  Re: more CMA kludge@panix.com (Scott Dorsey) - 2025-12-03 21:38 -0500
    Re: more CMA Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> - 2025-12-04 13:40 +0000
  Re: more CMA Roy Omond <roy@omond.net> - 2025-12-04 12:04 +0000
    Re: more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-04 09:23 -0500
      Re: more CMA Volker Halle <volker_halle@hotmail.com> - 2025-12-04 16:48 +0100
        Re: more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-04 11:55 -0500
      Re: more CMA Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> - 2025-12-04 18:29 +0000
        Re: more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-04 14:12 -0500
          Re: more CMA Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> - 2025-12-04 19:49 +0000
            Re: more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-04 15:59 -0500
              Re: more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-06 11:23 -0500
                Re: more CMA cross@spitfire.i.gajendra.net (Dan Cross) - 2025-12-08 20:55 +0000
                Re: more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-08 21:06 -0500
                Re: more CMA cross@spitfire.i.gajendra.net (Dan Cross) - 2025-12-09 04:46 +0000
          Re: more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-04 16:55 -0500
            Re: more CMA cross@spitfire.i.gajendra.net (Dan Cross) - 2025-12-05 17:15 +0000
              Re: more CMA Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> - 2025-12-05 18:06 +0000
                Re: more CMA cross@spitfire.i.gajendra.net (Dan Cross) - 2025-12-08 12:33 +0000
              Re: more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-05 18:39 -0500
                Re: more CMA cross@spitfire.i.gajendra.net (Dan Cross) - 2025-12-08 14:14 +0000
      Re: more CMA hb0815 <mw40171@mucweb.de> - 2025-12-05 21:52 +0100
        Re: more CMA Arne Vajhøj <arne@vajhoej.dk> - 2025-12-05 18:21 -0500

csiph-web