BartoszKP BartoszKP - 22 days ago 14
C++ Question

What does "Error 309" mean?

In our build we're creating an executable file with unit tests like this:

tests = env.Program(os.path.join(env['testDir'], name + '_test'),
src + createManifest(env),
LIBS = libs,
LIBPATH = buildLibPath(env),
LINKFLAGS = env['LINKFLAGS'],
CPPPATH = cppPath)


This correctly creates an executable, which later is being run by the following builder:

action = tests[0].abspath + '&& echo %DATE% %TIME% > ${TARGET}'
runTests = env.Command(source = tests,
target = 'test_'+name+'.tmp',
action = action)


Up to this point everything works fine: the tests are being run during the build.

I've recently found Visual Leak Detector tool and wanted to include this in the build. So, I've changed the environment for the builders like this:

vldInclude = os.path.join(os.path.normpath(env['vldIncDir']), 'vld.h')
env.Append(CPPFLAGS='/FI' + vldInclude)
env.Append(LIBPATH = env['vldLibDir'])
vldLib = os.path.join(env['vldLibDir'], 'vld.lib')
libs.append(vldLib) # used in the Program call for the LIBS parameter, see above



scons: *** [build\debug\libname\test_libname.dummy] Error 309


This error message isn't very helpful. What does it mean and how to fix it?

Answer

It turns out that the magic number 309 is more googleable when written as: 0xC0000135 (no idea why C, but 135HEX == 309DEC), and it is an identifier of the STATUS_DLL_NOT_FOUND error.

So, it's not a SCons error, but Windows error, that leaks through SCons.

This means that some DLLs are missing, needed by VLD. Lurking into the VLD installation directory (usually: C:\Program Files (x86)\Visual Leak Detector) two DLL files and one manifest file can be found in the bin\Win32 subdirectory. It's best to copy them to the directory where the tests are being run, not to have the build being dependent on the machine's environment. So, you need another VLD configuration option, beside the library directory, namely the binaries directory. Let's call it vldBinDir. At the build's startup you can copy these files to the build directory:

def setupVld(env):
    sourcePath = env['vldBinDir']
    targetPath = env['testDir']

    toCopy = ['dbghelp.dll',
              'vld_x86.dll',
              'Microsoft.DTfW.DHL.manifest']

    nodes = []
    for c in toCopy:
        n = env.Command(os.path.join(targetPath, c),
                        os.path.join(sourcePath, c),
                        SCons.Defaults.Copy("${TARGET}", "${SOURCE}"))
        nodes.append(n)

    env['vldDeps'] = nodes

And then, when creating particular tests, make sure to add the dependency:

for n in env['vldDeps']:
    env.Depends(tests, n)
Comments