#1349 Crash when compiling array of negative size

closed-fixed
5
2013-05-25
2007-06-27
Patryk
No

Compiler crashes after unusually long compile time (few minutes on AMD Athlon XP 1700+, WXP HE PL SP2).

Source:
xdata char tbl[-5] = {10};

command:
sdcc -c Source5.c

SDCC version:
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.7.2 #4852 (Jun 15 2007) (MINGW32)

Error message:
Assertion failed: dbuf->buf != NULL, file /home/sdcc-builder/build/sdcc-build/or
ig/sdcc/src/../support/Util/dbuf_string.c, line 153

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Caught signal 22: SIGABRT

Expected behaviour: report error (array size negative).

Discussion

  • Borut Ražem

    Borut Ražem - 2007-06-27
    • milestone: --> fixed
    • assigned_to: nobody --> borutr
    • status: open --> closed-fixed
     
  • Borut Ražem

    Borut Ražem - 2007-06-27

    Logged In: YES
    user_id=568035
    Originator: NO

    Fixed in svn revision #4867.

    Borut

     
  • Patryk

    Patryk - 2007-06-28

    Logged In: YES
    user_id=1788180
    Originator: YES

    Great!
    BTW: you mean #4862?

     
  • Patryk

    Patryk - 2007-06-28

    Logged In: YES
    user_id=1788180
    Originator: YES

    Huh? Just found #4867 snapshot released. #4862 was latest just few minutes ago. What time snapshots are released? Or some browser cache issues?

     
  • Borut Ražem

    Borut Ražem - 2007-06-28

    Logged In: YES
    user_id=568035
    Originator: NO

    Svn revision number is changed on every commit. There might be several commits between two snapshot builds, so don't assume:

    new_snapshot_build_number) == old_snapshot_build_number + 1

    but the following is always true:

    new_snapshot_build_number > old_snapshot_build_number

    Svn revision number is known at the commit time, which might be quite some time before the next snapshot build is available.

    Borut

     
  • Patryk

    Patryk - 2007-06-28

    Logged In: YES
    user_id=1788180
    Originator: YES

    I supposed it is like you wrote, but isn't new snapshot builds available around midnight? I.e. #4862 contains all updates committed during June 27, and #4867 all during June 28, so today (June 28) #4862 is the latest and contain your fix done June 27. Apparently not since #4867 became available today around noon.

     
  • Borut Ražem

    Borut Ražem - 2007-06-28

    Logged In: YES
    user_id=568035
    Originator: NO

    What do you mean with "midnight"? At which part of the world?
    That's why I renamed "Nightly snapshot builds" to just "Snapshot builds" ;-)

    Linux (i386 and amd64) and Windows builds start at 7h GMT and are available at cca. 8h GMT, Mac OS X build starts at 8h GMT and is available at cca. 9h GMT.

    Borut

     
  • Patryk

    Patryk - 2007-06-29

    Logged In: YES
    user_id=1788180
    Originator: YES

    I see. I meant midnight of GMT. Anyway #4867 wasn't available around 09:35 GMT, but it must been some browser or server cache issue.

    Now I can use:
    typedef char TCompile_time_check[(sizeof(buf) >= sizeof(the_largest_object)) ? 1 : -1];
    for some code sanity checks.

    Or more convenient with macro:
    #define GLUE_B(x, y) x##y
    #define GLUE(x, y) GLUE_B(x, y)
    #define COMPILE_TIME_CHECK(expr) typedef char GLUE(TCTChk_, __LINE__)[(expr) ? 1 : -1]

    COMPILE_TIME_CHECK(sizeof(buf) >= sizeof(the_largest_object));

    #define MAX_U_VAL(x) ( UINTMAX_MAX >> ((sizeof(UINTMAX_MAX) - sizeof(x))*CHAR_BIT) )
    COMPILE_TIME_CHECK( MAX_U_VAL(table_index) >= (sizeof(table)/sizeof(table[0])) );

     
  • Borut Ražem

    Borut Ražem - 2007-06-30

    Logged In: YES
    user_id=568035
    Originator: NO

    I made some mistakes in my previous posting:

    - Mac OS X build starts at 7h GMT and is available at cca. 8h GMT,
    - Linux (i386 and amd64) and Windows builds start at 8h GMT and are available at cca. 9:45h GMT

    Borut

     
  • Patryk

    Patryk - 2007-07-02

    Logged In: YES
    user_id=1788180
    Originator: YES

    That means there were no browser or server cache issues :-)

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks