Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#78 NASM core dumps

Ed Beroset

NASM core dumps when it encounters a label name
that consists of more than 4,095 characters. The
culprit is PERMTS_SIZE in labels.c.

The solution is to perform a strlen(label) check
at the very beginning of find_label(), and emit
a fatal error if it exceeds PERMTS_SIZE-1.

Unfortunately this will require that an efunc is
handed to find_label(). Which in turn means the
efunc needs to be handed to lookup_label() and
is_extern(). (The other functions that make use
of find_label(), already get the efunc.)

One alternative would be to hand the efunc to
init_labels(), so that it can be stored inside
a variable that's local to labels.c. (This seems
to be the approach used by other modules which
use efunc a lot.)

Another alternative would be to stop handing the
efunc around everywhere, and instead introduce a
global variable that points to the efunc. (This
would allow us to throw errors anywhere.)

Check the expert's forum for a thread on this.

In any case the 4,095 character limit should be
documented in the NASM manual.

PS: I'll spare you a piece of sample code -- it's
really easy to type one of those lengthy labels.


  • Ed Beroset
    Ed Beroset

    Logged In: YES

    I have addressed the issue by resolving it at the front end
    -- nasm now silently truncates the input token at 4095
    characters during the scanning phase (look for the token
    IDLEN_MAX in the source to find the relevant changes). It
    might be argued that the scanner could issue a warning, but
    I will leave that as a future enhancement. I will be
    modifying the manual to reflect this new reality.

  • Ed Beroset
    Ed Beroset

    • assigned_to: nobody --> beroset
    • status: open --> closed
  • Ed Beroset
    Ed Beroset

    • status: closed --> closed
  • Logged In: YES

    Only the label manager has a problem with
    identifiers whose names exceed a certain
    length. The preprocessor, for example, is
    perfectly capable of handling very long
    macro names.

    So truncating all identifiers in nasmlib.c
    may not be ideal.

    And doing so silently, definitely is not.
    At least warn.

    Ideally labels.c would allocate permts.data