Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: json out of bounds in batchrouter #2465

Merged
merged 12 commits into from Oct 3, 2022
Merged

Conversation

lvrach
Copy link
Member

@lvrach lvrach commented Sep 22, 2022

Description

We started to observe panics in the following line after we migrated to jsoniter library
err = json.Unmarshal(job.Parameters, &parameters)

I reproduced the panic by modifying the slice capacity whilst parsing it. Unfortunately, that was not enough to prove or to help find the root cause of the problem.

As a mitigation step and to increase observability, I have introduced a wrapper, that in case of panic, prints useful information and fallbacks to the standard JSON library

Notion Ticket

https://www.notion.so/rudderstacks/Batch-router-unmarshaling-slice-bounds-out-of-range-8294d65d8f014c13904980d2c6c34713

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@lvrach lvrach changed the base branch from master to release/1.1.x September 23, 2022 11:14
@lvrach lvrach changed the title Fix/json out of bounds fix: json out of bounds in batchrouter Sep 23, 2022
@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Base: 41.44% // Head: 36.11% // Decreases project coverage by -5.32% ⚠️

Coverage data is based on head (2250548) compared to base (867123a).
Patch coverage: 59.09% of modified lines in pull request are covered.

❗ Current head 2250548 differs from pull request most recent head 43ce0b4. Consider uploading reports for the commit 43ce0b4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2465      +/-   ##
==========================================
- Coverage   41.44%   36.11%   -5.33%     
==========================================
  Files         175      200      +25     
  Lines       36288    39662    +3374     
==========================================
- Hits        15039    14324     -715     
- Misses      20313    24435    +4122     
+ Partials      936      903      -33     
Impacted Files Coverage Δ
warehouse/snowflake/snowflake.go 0.00% <0.00%> (ø)
router/batchrouter/batchrouter.go 34.01% <60.00%> (+0.17%) ⬆️
...connection-tester/destination_connection_tester.go 15.38% <100.00%> (+0.14%) ⬆️
services/streammanager/streammanager.go 0.00% <0.00%> (-100.00%) ⬇️
utils/logger/logger.go 0.00% <0.00%> (-97.40%) ⬇️
warehouse/constraint.go 0.00% <0.00%> (-89.24%) ⬇️
services/stats/stats.go 10.74% <0.00%> (-77.75%) ⬇️
config/config.go 6.68% <0.00%> (-76.65%) ⬇️
services/metric/manager.go 0.00% <0.00%> (-50.00%) ⬇️
services/filemanager/filemanager.go 36.70% <0.00%> (-17.84%) ⬇️
... and 110 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lvrach lvrach marked this pull request as ready for review September 26, 2022 09:21
@lvrach lvrach requested review from atzoum, fracasula and a team September 26, 2022 09:36
Copy link
Collaborator

@fracasula fracasula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK as a temporary solution, I'll try to understand the root cause and see if we can remove the copy.

router/batchrouter/batchrouterBenchmark_test.go Outdated Show resolved Hide resolved
router/batchrouter/batchrouterBenchmark_test.go Outdated Show resolved Hide resolved
router/batchrouter/batchrouter.go Outdated Show resolved Hide resolved
router/batchrouter/batchrouter.go Outdated Show resolved Hide resolved
@fracasula fracasula changed the base branch from release/1.1.x to master October 3, 2022 14:44
@fracasula fracasula merged commit 2bf0f6a into master Oct 3, 2022
@fracasula fracasula deleted the fix/json-out-of-bounds branch October 3, 2022 16:04
This was referenced Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants