Hi, William.

Thaks for your response. I appreciated it.

I'm triing to reproduce the problem with a more basic program, and some constants autogenerated, but we obtain another diferent error or limitation on the tests.

It seems that there is a limit when you define more than 64K constants with .h files:

Up to 64K constants a pike will compile correctly  (32 files .h with 2001 constants each one) .

After include the 33rth file, seems that exceeds the current capacity: 'too many identifiers'.

datos_33.h:1549:Too many identifier_references.
datos_33.h:1550:Too many identifiers.
Violación de segmento (`core' generado)

I've done the test in two systems:
  Rocky   with    4GB RAM  Pike v8.0 release 1116
  Mint19 with  15GB RAM  Pike v8.0 release 498

If I compare this situation whith the other one, that results in the malloc error (corrupted size vs. prev_size) is not really comprensible, because the program that fails
does not exceed these limits, but fails when I add a new .h.


** malloc error    (corrupted size vs. prev_size)
number of constants in .h files:  1545
size of .h files .........................:   680KB


** max constants error  (Too many identifiers.)
number of constants in .h files....: Fine up to 64.000 (up to 33.h)
total size for the 40 .h files..........:   298MB

As you can see I'm getting the malloc error with only 1500 constants defined (<64K)  and no more thant 1MB of data payload.

Below you have the content of 3 files to autogenerate the .h payload and test these situations:
First run with includes commented to generate a payload.
Then run with the include.h enabled to see the result.

$ cat include_0.h
constant SALTO="\n\n";


$ cat includes.h
#ifndef INCLUDES_H
#define INCLUDES_H
#include "./datos_1.h"
#include "./datos_2.h"
#include "./datos_3.h"
#include "./datos_4.h"
#include "./datos_5.h"
#include "./datos_6.h"
#include "./datos_7.h"
#include "./datos_8.h"
#include "./datos_9.h"
#include "./datos_10.h"
#include "./datos_11.h"
#include "./datos_12.h"
#include "./datos_13.h"
#include "./datos_14.h"
#include "./datos_15.h"
#include "./datos_16.h"
#include "./datos_17.h"
#include "./datos_18.h"
#include "./datos_19.h"
#include "./datos_20.h"
#include "./datos_21.h"
#include "./datos_22.h"
#include "./datos_23.h"
#include "./datos_24.h"
#include "./datos_25.h"
#include "./datos_26.h"
#include "./datos_27.h"
#include "./datos_28.h"
#include "./datos_29.h"
#include "./datos_30.h"
#include "./datos_31.h"
#include "./datos_32.h"
#include "./datos_33.h"
#include "./datos_34.h"
#include "./datos_35.h"
#include "./datos_36.h"
#include "./datos_37.h"
#include "./datos_38.h"
#include "./datos_39.h"
#include "./datos_40.h"
#endif


$ cat includes.pike
#!/usr/bin/pike
#include "./include_0.h"

//Once autogenerated the payload, uncomment next line to include the of h files:  datos 1 a 40
//  #include "./includes.h"

int main()
{
    string PAYLOAD="ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
PAYLOAD=PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+
PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+
PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD+PAYLOAD;

    for (int i=1;i<=40; i++)
    {
        string f="./datos_"+i+".h";
        if (Stdio.is_file(f))
            continue;
        else
            Stdio.stdout.write("#include \"./datos_"+i+".h\"\n");

string AUX=""+
"#ifdef DATOS_"+i+"_H\n"+
"#warning Ya se ha hecho include previamente del fichero de constantes tsa_mail_ES.h\n"+
"\n"+
"#else\n"+
"#define DATOS_"+i+"_H\n"+
"\n";
        Stdio.append_file(f, AUX);

        for (int j=0; j<2000; j++)
        {
            Stdio.append_file(f, "constant CT_"+i+"_"+j+"=\""+PAYLOAD+"\"\+SALTO;\n");
        }

        Stdio.append_file(f, "\n#endif\n");
    }

   Stdio.stdout.write("ALL DONE!\n");

   thread_create(nothing);
   return -1;
}

void nothing()
{
while(1)
{
sleep(1);
}
}


On the test callbacks are enabled only to reproduce another running condition.

If anyone has more ideas to try, comments will be appreciated.

Best Regards

David Estopà




El 28/4/22 a las 2:56, H William Welliver escribió:
Just a quick update: I wrote a (basically empty) program that included 20 empty 
files and had no problems on 8.0.1116. So there must be something more to it. 
If you can find a minimal test case, we might have better luck.

Bill

On Apr 26, 2022, at 11:01 AM, David Estopa <dest...@lleida.net> wrote:

Hello, Friends of Pike!

On Pike 8.0 1116,   have anybody experienced similar malloc error trying to 
include several .h files into a program?

   malloc(): invalid next size (unsorted)
   corrupted size vs. prev_size

My program includes several .h to define several languages constants. If I 
include 18 works fine, but cannot include one more.

Is there a max size limit to include files into a pike program?

Thanks in advance.

David Estopà


Reply via email to