Ticket #9917 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

ECL has too few arguments and two many on file dpp.c

Reported by: drkirkby Owned by: GeorgSWeber
Priority: major Milestone: sage-4.6
Component: build Keywords: ecl
Cc: jhpalmieri Work issues:
Report Upstream: Fixed upstream, in a later stable release. Reviewers: John Palmieri
Authors: David Kirkby, Leif Leonhardy Merged in: sage-4.6.alpha2
Dependencies: Stopgaps:

Description (last modified by drkirkby) (diff)

When I'm building ecl-10.2.1 as part of Sage I get too warning messages from gcc.

/export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p2/src/src/c/dpp.c: In function 'put_declaration':
/export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p2/src/src/c/dpp.c:678:5: warning: too few arguments for format
/export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p2/src/src/c/dpp.c:680:13: warning: too many arguments for format

Looking at line 678 of dpp.c, I see:

    fprintf(out, "\tif (ecl_unlikely(narg!=%d))");

So there's a %d, but what is associate with the %d? There should be an integer, but there is not one. So it seems to me gcc is right to complain there are too few arguments for format.

Likewise, on line 680, I see:

    fprintf(out, "\t   FEwrong_num_arguments(MAKE_FIXNUM(%d));\n",
            nreq, function_code);

There we observe two arguments supplied, but only one %d is there. That does not make any sense to me. Both "nreq" and "function_code" are declared as integers, so should there not two %d's and not one.

Again, it seems gcc is right to complain that.

There are thousands of warning messages in Sage, but I'm a bit concerned about resolving those in ecl, as the ecl library being built has text relocation problems - see #9840

Dave

Attachments

9917-makes-changes-to-dpp.c.patch Download (20.5 KB) - added by drkirkby 3 years ago.
Makes acouple of changes to the file dpp.c, which will remove a couple of compiler warnings which looked potentially harmful.
9917-non-empty-patch-file.patch Download (1.0 KB) - added by drkirkby 3 years ago.
Somehow the previous patch file I made was empty - this corrects that.

Change History

comment:1 Changed 3 years ago by drkirkby

  • Description modified (diff)

comment:2 Changed 3 years ago by leif

Perhaps temporarily fix this in Sage's 10.2.1 by patching it to the obvious:

    fprintf(out, "\tif (ecl_unlikely(narg!=%d))", nreq);

and

    fprintf(out, "\t   FEwrong_num_arguments(MAKE_FIXNUM(%d));\n",
            function_code);

(You don't have to report this upstream since it is already fixed.)

comment:3 Changed 3 years ago by drkirkby

Yes, I just downloaded the latest ecl using "git" and it is indeed fixed upstream. I'll create a package with the upstream fixes to these two lines of code. It will remove two warnings. I doubt it is the cause of my relocation problems, but at least it will not leave me wondering if it is.

comment:4 Changed 3 years ago by drkirkby

  • Status changed from new to needs_info
  • Authors set to David Kirkby, Leif Leonhardy

Now when this is compiled, the warnings messages have gone:

        gcc -I/export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p3/src/src/c -I/export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p3/src/build -I./ /export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p3/src/src/c/dpp.c  -I/export/home/drkirkby/sage-4.6.alpha0/local/include  -O2  -g  -Wall  -fPIC  -Dsun4sol2 -o dpp 

An updated package can be found at

 http://boxen.math.washington.edu/home/kirkby/patches/ecl-10.2.1.p3.spkg

This needs further testing, as I've only currently tested this on OpenSolaris, but I think it is as safe as a bank vault. Hence for now I've marked it "needs info" until such time as I can confirm it works fully on other systems.

Dave

Changed 3 years ago by drkirkby

Makes acouple of changes to the file dpp.c, which will remove a couple of compiler warnings which looked potentially harmful.

comment:5 Changed 3 years ago by drkirkby

  • Cc jhpalmieri added
  • Status changed from needs_info to needs_review
  • Report Upstream changed from N/A to Fixed upstream, but not in a stable release.

I've checked this now on OpenSolaris, Solaris 10 on SPARC (t2). Linux (sage.math) and OS X (bsd.math).

ECL installed ok on all of them. Maxima failed on OS X, but the failure is already known - see #8645.

As such, I'm now marking this for review. I don't know whether fixing these compiler warnings will solve the problems on Solaris (I doubt it will), but its not a good idea to have code like it was before.

Since this is already fixed upstream in their git repository, I've marked it as such.

Dave

comment:6 follow-up: ↓ 11 Changed 3 years ago by jhpalmieri

In the spkg, the file dpp.c.patch is empty. That should be fixed. Other than that, the changes look fine. I'll test it on a few systems, but I can't imagine there being a problem.

Regarding

    fprintf(out, "\t   FEwrong_num_arguments(MAKE_FIXNUM(%d));\n",
            nreq, function_code);

I find it amusing that this problem occurs in a line containing "wrong_num_arguments"...

comment:7 Changed 3 years ago by leif

It's also fixed in 10.4.1, which I think is a stable release.


That's called "Literal programming" I think, self-referential.

comment:8 Changed 3 years ago by leif

  • src/src/c/dpp.c

    diff -Nu ecl-10.2.1.p1/src/src/c/dpp.c ecl-10.4.1/src/src/c/dpp.c
    old new  
    251251} 
    252252 
    253253char * 
    254 search_symbol(char *name, int *symbol_code) 
     254search_symbol(char *name, int *symbol_code, int code) 
    255255{ 
    256256        int i; 
    257257        for (i = 0; cl_symbols[i].name != NULL; i++) { 
    258258                if (!strcasecmp(name, cl_symbols[i].name)) { 
    259259                        name = poolp; 
    260                         if (i == 0) { 
     260                        if (code) { 
     261                                pushstr("MAKE_FIXNUM(/*"); 
     262                                pushstr(cl_symbols[i].name); 
     263                                pushstr("*/"); 
     264                                if (i >= 1000) 
     265                                        pushc((i / 1000) % 10 + '0'); 
     266                                if (i >= 100) 
     267                                        pushc((i / 100) % 10 + '0'); 
     268                                if (i >= 10) 
     269                                        pushc((i / 10) % 10 + '0'); 
     270                                pushc(i % 10 + '0'); 
     271                                pushstr(")"); 
     272                                pushc(0); 
     273                        } else if (i == 0) { 
    261274                                pushstr("Cnil"); 
    262275                                pushc(0); 
    263276                        } else { 
     
    283296} 
    284297 
    285298char * 
    286 read_symbol() 
     299read_symbol(int code) 
    287300{ 
    288301        char c, *name = poolp; 
     302        char end = code? ']' : '\''; 
    289303 
    290304        c = readc(); 
    291         while (c != '\'') { 
     305        while (c != end) { 
    292306                if (c == '_') c = '-'; 
    293307                pushc(c);  
    294308                c = readc(); 
    295309        } 
    296310        pushc(0); 
    297311 
    298         name = search_symbol(poolp = name, 0); 
     312        name = search_symbol(poolp = name, 0, code); 
    299313        if (name == NULL) { 
    300314                name = poolp; 
    301315                printf("\nUnknown symbol: %s\n", name); 
     
    387401                } else if (c == '@') { 
    388402                        c = readc(); 
    389403                        if (c == '\'') { 
    390                                 (void)read_symbol(); 
     404                                (void)read_symbol(0); 
     405                                poolp--; 
     406                        } else if (c == '[') { 
     407                                (void)read_symbol(1); 
    391408                                poolp--; 
    392409                        } else if (c == '@') { 
    393410                                pushc(c); 
     
    448465get_function(void) 
    449466{ 
    450467        function = read_function(); 
    451         function_symbol = search_symbol(function, &function_code); 
     468        function_symbol = search_symbol(function, &function_code, 0); 
    452469        if (function_symbol == NULL) { 
    453470                function_symbol = poolp; 
    454471                pushstr("Cnil"); 
     
    675692  } 
    676693  if (nopt == 0 && !rest_flag && !key_flag) { 
    677694    put_lineno(); 
    678     fprintf(out, "\tif (ecl_unlikely(narg!=%d))"); 
     695    fprintf(out, "\tif (ecl_unlikely(narg!=%d))", nreq); 
    679696    fprintf(out, "\t   FEwrong_num_arguments(MAKE_FIXNUM(%d));\n", 
    680             nreq, function_code); 
     697            function_code); 
    681698  } else { 
    682699    simple_varargs = !rest_flag && !key_flag && ((nreq + nopt) < 32); 
    683700    if (key_flag) { 
     
    833850        } else if (c == '\'') { 
    834851                char *p; 
    835852                poolp = pool; 
    836                 p = read_symbol(); 
     853                p = read_symbol(0); 
     854                pushc('\0'); 
     855                fprintf(out,"%s",p); 
     856                goto LOOP; 
     857        }  else if (c == '[') { 
     858                char *p; 
     859                poolp = pool; 
     860                p = read_symbol(1); 
    837861                pushc('\0'); 
    838862                fprintf(out,"%s",p); 
    839863                goto LOOP; 

If that convinces you more.

comment:9 Changed 3 years ago by leif

s/literal/literate/

It's getting late...

Changed 3 years ago by drkirkby

Somehow the previous patch file I made was empty - this corrects that.

comment:10 Changed 3 years ago by drkirkby

I've updated the patch file - I've no idea how I managed to make it empty before!

There are of course several changes to the upstream code, but since the snapshot I took was an unstable release, I think it is wise to limit the changes to just what were causing a problem in Sage.

I'm not sure if there is a later stable release available or not - I've found the version number at the top right of the ECL web site rarely agrees with the version number one can actually download. I think we probably have the latest stable release due to a comment made by Juanjo on the ECL mailing list in my response to my question about this matter.

Sage cannot rely on unstable releases, which is why I was slowly working on another stable release -- unfortunately actual work got in the way.

Juanjo

I've updated the .spkg at

 http://boxen.math.washington.edu/home/kirkby/patches/ecl-10.2.1.p3.spkg

Dave

comment:11 in reply to: ↑ 6 Changed 3 years ago by drkirkby

Replying to jhpalmieri:

I find it amusing that this problem occurs in a line containing "wrong_num_arguments"...

Yes the line in ECL is rather funny. It's a bit like that ATLAS file make_correct_shared.sh, which seems to screw up making the shared libraries!

Dave

comment:12 Changed 3 years ago by jhpalmieri

  • Status changed from needs_review to positive_review
  • Reviewers set to John Palmieri

comment:13 Changed 3 years ago by leif

  • Report Upstream changed from Fixed upstream, but not in a stable release. to Fixed upstream, in a later stable release.

comment:14 Changed 3 years ago by mpatel

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.6.alpha2
Note: See TracTickets for help on using tickets.