OK, so after a bit of hackery to get this code to link,
the first program using the DEBUG version of Judy
now crashes with a segfault:

Error running ‘build/release/host/bin/flx_pkgconfig 
--path+=build/release/host/config --field=includes 
@build/release/cache/text/Users/skaller/felix/build/release/share/src/tools/bootflx.resh'
 exited with -11

I had to do a couple of changes:

In JudyDel.c: add “static”

DBGCODE(static uint8_t parentJPtype;)          // parent branch JP type.

In Judy.h: interfaces for debug routines:


#ifdef DEBUG
extern void JUDY_EXTERN Judy1CheckPop ( Pvoid_t PArray);
extern void JUDY_EXTERN JudyLCheckPop ( Pvoid_t PArray);
extern void JUDY_EXTERN Judy1CheckSorted (
        Pvoid_t x,              // leaf or list to check.
        Word_t y,               // number of indexes to check.
        long z// bytes per index in list.
);      
extern void JUDY_EXTERN JudyLCheckSorted ( 
        Pvoid_t x,              // leaf or list to check.
        Word_t y,               // number of indexes to check.
        long z// bytes per index in list.
);      
#endif

In JudyPrivate1L.h: arrange debug routines to make two versions:

#ifdef DEBUG
#define JudyCheckPop            Judy1CheckPop
#define JudyCheckSorted         Judy1CheckSorted
#endif

and

#ifdef DEBUG
#define JudyCheckPop            JudyLCheckPop
#define JudyCheckSorted         JudyLCheckSorted
#endif

in JudyGet.c: Corrrect linkage specification with JUDY_EXTERN


FUNCTION void JUDY_EXTERN JudyCheckPop (
        Pvoid_t PArray)

FUNCTION void JUDY_EXTERN JudyCheckSorted(
        Pjll_t Pjll,            // leaf or list to check.
        Word_t Pop1,            // number of indexes to check.
        long   IndexSize)       // bytes per index in list.
{


FYI: JUDY_EXTERN is a macro that Felix uses when building or using
Judy that changes in meaning depending on whether you’re building
or using it. For dynamic linkage, it ensures _dllexport on building
and _dllimport on using. This has always been mandatory on Windows
when using DLLs. It is also now recommended for Linux (and OSX),
although .. as you might expect .. the Unix nerds in their wisdom implement
something different.

Export and import linkage controls provide visibility control similar
to static/extern, but one level up, at the DLL/shared library level.
Felix demands this control so no code designed for static linkage
only can work for Felix, it all has to be modified to pick out
exactly which extern symbols are actually exported from a DLL.

So now, the results:

On OSX under Clang: I get a segfault with no diagnostics.

On Travis, running Linux with gcc, I get a run time library diagnostic:

*** Error in `build/release/host/bin/flx_pkgconfig': double free or corruption 
(!prev): 0x000000000139bb20 ***
 + build/release/host/bin/flx_pkgconfig --path+=build/release/host/config 
--field=includes 
@build/release/cache/text/home/travis/build/felix-lang/felix/build/release/share/src/tools/bootflx.resh
Error running ‘build/release/host/bin/flx_pkgconfig 
--path+=build/release/host/config --field=includes 
@build/release/cache/text/home/travis/build/felix-lang/felix/build/release/share/src/tools/bootflx.resh'
 exited with -6

On Appveyor, running Windows with MSVc++ I get an assertion failure:

Assertion failed: FALSE, file 
c:\projects\felix\build\release\share\src\judy\src\judyl\../JudyCommon/JudyGet.c,
 line 1150
Error running 'build\\release\\host\\bin\\flx_pkgconfig 
--path+=build\\release\\host\\config --field=includes 
@build\\release\\cache\\text\\C\\\\projects\\felix\\build\\release\\share\\src\\tools\\bootflx.resh'
 exited with 3
NMAKE : fatal error U1077: 'C:\Python35-x64\python.EXE' : return code '0x1'
Stop.

My file is modified so I will show the source code:


#define JU_CHECKSORTED_ODD(CopyIndex)                   \
        {                                               \
            Word_t indexlow;                            \
            Word_t indexhigh;                           \
            long   offset;                              \
                                                        \
            CopyIndex(indexlow, (uint8_t *) Pjll);      \
                                                        \
            for (offset = 1; offset < Pop1; ++offset)   \
            {                                           \
                CopyIndex(indexhigh,                    \
                          ((uint8_t *) Pjll) + (offset * IndexSize)); \
                assert(indexlow < indexhigh);           \
                indexlow = indexhigh;                   \
            }                                           \
            break;                                      \
        }

        switch (IndexSize)
        {
        case 1: JU_CHECKSORTED(uint8_t *);
        case 2: JU_CHECKSORTED(uint16_t *);
        case 3: JU_CHECKSORTED_ODD(JU_COPY3_PINDEX_TO_LONG);
        case 4: JU_CHECKSORTED(uint32_t *);
#ifdef JU_64BIT
        case 5: JU_CHECKSORTED_ODD(JU_COPY5_PINDEX_TO_LONG);
        case 6: JU_CHECKSORTED_ODD(JU_COPY6_PINDEX_TO_LONG);
        case 7: JU_CHECKSORTED_ODD(JU_COPY7_PINDEX_TO_LONG);
        case 8: JU_CHECKSORTED(Pjlw_t);
#endif
        default:  assert(FALSE);        // invalid IndexSize.
        }


That final assert is the error.

So to me, all this means:

(1) The Judy Check routines have bugs in them :)

(2) The diagnostic on Windows is because there is a bug in MY PORT of
Judy so it works on Windows.

I didn’t try to port the Check routines. I think I will change that default
case to actually print the bad index size.

—
john skaller
[email protected]
http://felix-lang.org


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel

Reply via email to