Open
Conversation
Install Jalangi2 (v0.2.6) and create custom dynamic analysis scripts targeting NodeBB code patterns. Includes three custom analyses (function tracer, type coercion detector, property access tracker), two target test scripts, instrumentation output, and a comprehensive output log demonstrating all analyses. Made-with: Cursor
Made-with: Cursor
2a48f69 to
de02891
Compare
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.
Installation Evidence
jalangi2v0.2.6 added as a dependency (seepackage.json,package-lock.json)jalangi-testing/directory including custom analyses, target scripts, instrumented output, and a comprehensive test logWhat is Jalangi2?
Jalangi2 is a dynamic analysis framework for JavaScript developed at Samsung Research and UC Berkeley. Unlike static analysis tools (ESLint, JSHint), Jalangi2 instruments code at runtime, intercepting every operation (function calls, property accesses, binary operations, branches, etc.) and allowing custom analysis callbacks to observe or modify behavior during execution.
Artifacts
package.json/package-lock.jsonjalangi-testing/jalangi2-full-output.txtjalangi-testing/analysis-function-tracer.jsjalangi-testing/analysis-type-coercion-detector.jsjalangi-testing/analysis-property-access-tracker.jsjalangi-testing/target-nodebb-patterns.jsjalangi-testing/target-nodebb-realworld.jsjalangi-testing/instrumented/Analyses Run
Built-in analyses (from Jalangi2's dlint/tutorial suite):
parseUserAge()andisNumber()callsgreetUser(name)was called with 3 argsCustom analyses (written for this evaluation):
getUserByUidwas the most-called function (9x) and mapped caller→callee edges (e.g.,createTopic → getUserByUid6x)Performance Overhead
Assessment: Pros and Cons
Strengths
Unmatched runtime visibility: Jalangi2 intercepts every JavaScript operation — function calls, property accesses, binary ops, branches. No static tool can match this level of detail for understanding actual runtime behavior.
Highly customizable analysis framework: The callback API (
functionEnter,getField,putField,binary,conditional, etc.) makes it straightforward to write targeted analyses. Our 3 custom analyses (50-90 lines each) were able to detect real issues in NodeBB-style code.Catches bugs static tools miss: NaN propagation, implicit type coercions, and undefined property chains are runtime-only phenomena. Jalangi2 detected all of these in our tests (5 NaN sites, 6 type coercion warnings, 1 null-base property access).
Call graph and coverage data: The branch coverage and function tracer analyses provide quantitative data about code execution paths that's valuable for understanding test coverage and hotspots.
Good built-in analyses: The dlint suite (CheckNaN, UndefinedOffset, FunCalledWithMoreArguments, etc.) works out of the box and catches real JavaScript anti-patterns.
Weaknesses
No ES6+ support (critical for NodeBB): Jalangi2's instrumentation breaks
constandletdeclarations due to how it rewrites variable scoping. Running it directly on NodeBB source files (which use'use strict'+const/letthroughout) fails withReferenceError: Cannot access 'X' before initialization. This is a fundamental limitation — the tool cannot be used on modern JavaScript without transpilation.Significant performance overhead (~12.5x): Even a simple function tracer adds 12x slowdown. More complex analyses (property tracking) would be worse. This makes it impractical for large-scale or production use.
Requires code execution: Unlike static tools, Jalangi2 only analyzes code paths that are actually exercised. Dead code, rare error paths, and untested branches are invisible to it. You need good test coverage to get good analysis coverage.
No async/await or Promise support: Jalangi2 was designed before modern async JavaScript. The
async/awaitpatterns used heavily in NodeBB's codebase are not properly tracked — async function boundaries, promise chains, and event loop behavior are opaque to the analysis.Stale/unmaintained: The last significant update to Jalangi2 was several years ago. No active maintenance means no fixes for modern Node.js compatibility issues.
Code bloat from instrumentation: Instrumentation expands a 137-line file to 300 lines (2.2x). For large codebases, this means significant memory and parsing overhead.
Customization Assessment
A priori customization needed:
varinstead ofconst/let) or the codebase must be transpiled with Babel before analysis// JALANGI DO NOT INSTRUMENTcomment--inlineIID --inlineSourceflags are needed for meaningful location reportingOver-time customization:
ChainedAnalyses.js) to run multiple checks in one passVerdict
Jalangi2 is a powerful but dated dynamic analysis framework. Its callback-based architecture for intercepting JavaScript operations is elegant and the analysis capabilities are genuinely useful for finding runtime bugs that static tools miss. However, the lack of ES6+ support is a dealbreaker for modern Node.js projects like NodeBB — it requires either transpilation or rewriting target code in ES5, which undermines its practical value. For a project that uses modern JavaScript throughout, static analysis tools (ESLint with appropriate plugins) combined with runtime monitoring (Node.js
--inspect, async_hooks) would provide better coverage with less friction.