#70/fix libsumo in-process start (missing geos DLLs) - #237
Open
yunlishao-vibe wants to merge 2 commits into
Open
#70/fix libsumo in-process start (missing geos DLLs)#237yunlishao-vibe wants to merge 2 commits into
yunlishao-vibe wants to merge 2 commits into
Conversation
libsumocpp.dll could not be loaded at all. CommonLib/libsumo/bin was missing geos_c.dll and its dependency geos.dll, two third-party libraries bundled with SUMO's own Windows distribution. gdal.dll (and spatialite.dll) import geos_c statically, so the whole chain failed to load. Because TrafficLayer delay-loads libsumocpp.dll (TrafficLayer.vcxproj <DelayLoadDLLs>, x64 Debug+Release), the breakage did not surface at startup. It surfaced on the first libsumo call - Simulation::start() - as a Win32 loader exception (0xC06D007E). That is not a C++ exception, so the try/catch around start() never ran: TrafficLayer died with no console output and nothing in TrafficLayer.err, after clients had already connected and were waiting. That is the "hang or exit" reported in #70. start() itself was never at fault; with a loadable build the identical argument list works. The external-process path was unaffected because it uses libtracicpp.dll, which has only 8 dependencies, all standard Windows ones, and never touches gdal. Changes: - CommonLib/libsumo/bin: add geos_c.dll + geos.dll from the official SUMO 1.22.0 Windows build (matches dependencies.yaml). Verified: the transitive dependency graph of libsumocpp/libsumocppD/libtracicpp/libtracicppD is now complete, and all four load. - TrafficHelper.cpp: drop setOrder() from the libsumo launch. libsumo rejects it at runtime ("Multi client support (including connection switching) is not implemented in libsumo"); the in-process simulation is the only client. - TrafficHelper.cpp: drop --num-clients from the libsumo argv (meaningless with no TraCI server) and document that --remote-port must never be added - it makes SUMO open a real TraCI server and block inside start() waiting for a client that never connects. Measured: start() blocked indefinitely until an external client attached, then returned after 21.4s. - TrafficHelper.cpp: under ENABLE_LIBSUMO, fail with an actionable message when EnableAutoLaunch is false. libsumo embeds the simulation and cannot attach to an externally running SUMO; init() is libtraci-only and throws there. - TrafficHelper.cpp: add libsumoPreflight(), which loads libsumocpp.dll explicitly before the first call so a missing dependency becomes a normal catchable error instead of a silent 0xC06D007E death. - pack_native_deps.ps1: verify the staged bin/ actually loads before packing. The published libsumo-1.22.0.zip has the same missing DLLs, so prebuilt fetches are broken identically; this stops a broken asset shipping again. - Correct the stale "This is the active implementation" comment: ENABLE_LIBSUMO is opt-in and commented out; stock builds use libtraci. ENABLE_LIBSUMO remains off by default. Both configurations compile.
5 tasks
…g them The previous commit removed --num-clients and setOrder() from the libsumo launch because libsumo has no TraCI server and rejects setOrder() at runtime. But SumoSetup.NumClients and SumoSetup.ExecutionOrder are user-facing YAML keys, so dropping them silently let a config ask for something the build cannot do while still appearing to run - the same silent-failure class as the bug this issue is about. Now: - NumClients != 1 is a hard error. Additional TraCI clients could never connect to an in-process simulation, so the run would be broken anyway; fail immediately with the reason and the two ways out. - ExecutionOrder != 1 warns and continues. With a single in-process client ordering is genuinely moot, so it is not worth failing a run over. Both configurations still compile.
Open
6 tasks
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the libsumo (in-process SUMO) path actually start. The blocker was not libsumo's
initialization logic — it was two missing DLLs that made
libsumocpp.dllimpossible to load.This adds them, removes two libtraci-only calls that would have failed immediately afterwards,
and stops the packaging script from publishing a broken artifact again.
ENABLE_LIBSUMOremains off by default — this repairs the opt-in path, it does not switch to it.Root Cause
CommonLib/libsumo/binwas missinggeos_c.dlland its own dependencygeos.dll, twothird-party libraries bundled with SUMO's Windows distribution.
gdal.dllandspatialite.dllimport
geos_cstatically, so the whole chain — and thereforelibsumocpp.dll— could not load.The reason it looked like a startup/sequencing bug: TrafficLayer delay-loads
libsumocpp.dll(
TrafficLayer.vcxproj<DelayLoadDLLs>, x64 Debug + Release). So nothing fails at process start.TrafficLayer boots, opens its socket and accepts clients (
mainTrafficLayer.cpp:795runs before:869). The first call that touches the library isSimulation::start(), so that is where theloader failure lands — as a Win32 structured exception
0xC06D007E, not a C++ exception.The
try/catcharoundstart()therefore never runs: the process dies with nothing on the consoleand nothing in
TrafficLayer.err, while already-connected clients sit waiting. That is preciselythe "hang or exit" described in the issue.
start()itself was never at fault. With a loadable build the byte-identical argument list works.This also explains why the external-process path was unaffected: it uses
libtracicpp.dll, whichhas only 8 dependencies, all standard Windows ones, and never touches gdal.
Evidence (delay-loaded probe mirroring
TrafficHelper.cpp's exact call sequence):Related Issues / Tasks
Closes #70.
Related: #109 (native-deps rolling release) — the published
libsumo-1.22.0.zipasset has thesame two DLLs missing, so prebuilt fetches are broken identically. See "Follow-up" below.
Type of Change
Affected Modules / Components
CommonLib/libsumo/bin/— addedgeos_c.dll(457 KB) andgeos.dll(2.5 MB), taken from theofficial SUMO 1.22.0 Windows build, matching the version pinned in
dependencies.yaml.CommonLib/TrafficHelper.cppsetOrder()from the libsumo launch. libsumo rejects it at runtime: "Multi clientsupport (including connection switching) is not implemented in libsumo." The in-process
simulation is the only client, so ordering is meaningless.
--num-clientsfrom the libsumo argv (no TraCI server exists in-process), anddocumented that
--remote-portmust never be added there — it makes SUMO open a realTraCI server and block inside
start()waiting for a client that never connects.ENABLE_LIBSUMO,EnableAutoLaunch: falsenow fails with an actionable message insteadof dying inside the library: libsumo embeds the simulation and cannot attach to an externally
running SUMO (
init()is libtraci-only and throws there).libsumoPreflight(), which loadslibsumocpp.dllexplicitly before the first call, so amissing dependency becomes a normal catchable error with a clear message rather than a silent
0xC06D007Edeath."This is the active implementation"comment —ENABLE_LIBSUMOis opt-inand commented out; stock builds use libtraci.
scripts/dispatch/pack_native_deps.ps1— verifies the stagedbin/actually loads before packing,so an incomplete folder cannot be published as a release asset again.
Test Cases
All measured on this branch; no full CarMaker/VISSIM co-sim was involved.
libsumocpp/libsumocppD/libtracicpp/libtracicppD(94 modules): missing third-party DLLs went fromgeos_c.dllto none.gdal.dllandspatialite.dllnow load(
LoadLibraryEx); previouslylibsumocpp.dllandgdal.dllfailed witherr=126.libsumocpp.libanddelay-loaded exactly as TrafficLayer is, replicating
TrafficHelper.cpp's sequence againsttests/Python/SimpleEchoClient/simple_loop.sumocfg. Before: died at0xC06D007E. After:start()returnsSUMO 1.22.0,step()andgetIDList()work,close()clean.This also empirically confirmed
setOrder()andinit()throw under libsumo.TrafficHelper.cppcompiles clean withENABLE_LIBSUMOdefined and undefined. The libsumo branch is not built by default, which is how it rotted;
it is now known to compile.
geos.dllremoved the packer refuses (GetLastError=126, exit 1,no zip written); with it present the check passes and packing proceeds.
--remote-porthang, characterised — confirmedstart()blocks indefinitely; it opens areal TraCI server and returned only after an external client attached (21.4 s). Not currently
passed by the code; documented so it is not added later.
Environment
Compiler: MSVC 19.29 (VS 2022), x64.
Checklist
Additional Notes
Follow-up required (not in this PR): the published
libsumo-1.22.0.zipon thefixs-native-depsrolling release is missing the same two DLLs, so anyone fetching prebuilt depsstill gets the broken set. It needs re-packing and re-publishing
(
pack_native_deps.ps1 -Component sumo -Publish). That overwrites a public release asset, so it isleft as a deliberate maintainer action rather than folded into this PR.
Scope note — libsumo cannot drive sumo-gui on Windows. Verified in both the Python and C++ APIs:
SUMO warns "Libsumo on Windows does not work with GUI, falling back to plain libsumo" and silently
runs headless (
hasGUI()false, no window). The same guard is compiled into the vendored 1.22.0binaries and into SUMO 1.27, so it is not a version or build-flag issue. Anything needing a visible
network must stay on the libtraci path. #70's acceptance criteria should be read as headless-only.
Priority note. With the #177 fix already on
dev_v0.9.0, the shipping libtraci path measures~1.17 ms/step vs ~0.26 ms/step in-process at N=23 on
simple_loop— against a 100 ms/step budget.libsumo's remaining benefit is therefore small for interactive co-sim and is mainly of interest for
headless batch runs, where the no-GUI limitation costs nothing.
Not verified: a full
TrafficLayer.exerun withENABLE_LIBSUMOenabled end-to-end againstSimpleEchoClient. That needs a complete dispatch build (yaml-cpp was not built in this worktree).The library-level sequence it depends on is verified above, but the last acceptance-criteria box in
#70 should be ticked by whoever runs the full build.