Skip to content

Enabled heap check (#1306)#1316

Merged
mattklein123 merged 4 commits intoenvoyproxy:masterfrom
mrice32:heap_check_fix
Jul 24, 2017
Merged

Enabled heap check (#1306)#1316
mattklein123 merged 4 commits intoenvoyproxy:masterfrom
mrice32:heap_check_fix

Conversation

@mrice32
Copy link
Member

@mrice32 mrice32 commented Jul 24, 2017

Fixes #1306. Heap check was disabled because the environment variables that enable it were not accessible to the running tests. This was fixed by explicitly adding those environment variables to the bazel test options. We now see stack traces for leaks like the following (symbol name availability depends on the build mode):

Leak of 8 bytes in 2 objects allocated from:
        @ 677c96 Envoy::Router::Filter::Filter
        @ 677b07 _ZN5Envoy6Router10ProdFilterCI2NS0_6FilterEERNS0_12FilterConfigE
        @ 958ec0 Envoy::Http::AsyncStreamImpl::AsyncStreamImpl
        @ 958757 Envoy::Http::AsyncRequestImpl::AsyncRequestImpl
        @ 958562 Envoy::Http::AsyncClientImpl::send
        @ 99f595 Envoy::Http::RestApiFetcher::refresh
        @ 99f3f5 Envoy::Http::RestApiFetcher::initialize
        @ 5885b9 Envoy::Upstream::CdsApiImpl::initialize
        @ 5667b9 Envoy::Upstream::ClusterManagerInitHelper::maybeFinishInitialize
        @ 566891 Envoy::Upstream::ClusterManagerInitHelper::onSt
Leak of 8 bytes in 2 objects allocated from:
        @ 677d38 Envoy::Router::Filter::Filter
        @ 677b07 _ZN5Envoy6Router10ProdFilterCI2NS0_6FilterEERNS0_12FilterConfigE
        @ 958ec0 Envoy::Http::AsyncStreamImpl::AsyncStreamImpl
        @ 958757 Envoy::Http::AsyncRequestImpl::AsyncRequestImpl
        @ 958562 Envoy::Http::AsyncClientImpl::send
        @ 99f595 Envoy::Http::RestApiFetcher::refresh
        @ 99f3f5 Envoy::Http::RestApiFetcher::initialize
        @ 5885b9 Envoy::Upstream::CdsApiImpl::initialize
        @ 5667b9 Envoy::Upstream::ClusterManagerInitHelper::maybeFinishInitialize
        @ 566891 Envoy::Upstream::ClusterManagerInitHelper::onSt

mattklein123
mattklein123 previously approved these changes Jul 24, 2017
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Sweet. Thanks @mrice32 !

dnoe
dnoe previously approved these changes Jul 24, 2017
Copy link
Contributor

@dnoe dnoe left a comment

Choose a reason for hiding this comment

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

Thanks for figuring this out

@htuch
Copy link
Member

htuch commented Jul 24, 2017

I think we should probably put this in tools/bazel.rc so it's picked up on non-Docker build as well.

@mattklein123
Copy link
Member

Oh yeah putting in bazel.rc would be great. Good call.

@mrice32 mrice32 dismissed stale reviews from dnoe and mattklein123 via b1a3ebf July 24, 2017 17:37
--jobs=${NUM_CPUS} --show_task_finish"
export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYTHONUSERBASE \
--test_env=HEAPCHECK --test_env=PPROF_PATH --cache_test_results=no --test_output=all"
--test_env=HEAPCHECK --test_output=all"
Copy link
Member

Choose a reason for hiding this comment

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

I think you were off-by-one in arg position in the cut+paste here..

tools/bazel.rc Outdated
build:clang-msan --copt -fsanitize-memory-track-origins=2

# Test options
test --test_env=HEAPCHECK --test_env=PPROF_PATH
Copy link
Member

Choose a reason for hiding this comment

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

Should this be --test_env=HEAPCHECK=normal? Is there a way to get the pprof location from the gperftools build in the local situation? Or if it's too complicated, what happens when you specify HEAPCHECK=normal but no PPROF_PATH?

Copy link
Member Author

@mrice32 mrice32 Jul 24, 2017

Choose a reason for hiding this comment

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

I think setting HEAPCHECK to normal in the bazel.rc is preferable. I'll do some testing. I think PPROF_PATH defaults to pprof (so it should find it if you have it installed). I'm not sure what happens if pprof doesn't exist. HEAPCHECK should work okay without using pprof anyway. It apparently just makes the heap check better.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nothing breaks if pprof isn't installed, and the heap checker still runs. Setting --test_env=HEAPCHECK=normal --test_env=PPROF_PATH should be fine in the bazel.rc. Note: If HEAPCHECK is explicitly set to normal in bazel.rc the user cannot override it by just exporting HEAPCHECK in their local environment. The user will have to explicitly set --test_env=HEAPCHECK (grabbing the env variable) or --test_env=HEAPCHECK=[user_setting] (modifying it in the command directly) to override the normal setting. Whatever we choose, I'll add it into the docs.

Copy link
Member

Choose a reason for hiding this comment

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

I don't have a strong opinion on which one is chosen as long as we doc it. Will let both of you choose.

@mrice32
Copy link
Member Author

mrice32 commented Jul 24, 2017

To be clear, putting this in bazel.rc will just import the environment variables. It will not set them. So to enable the heap check, the user will need to export HEAPCHECK=normal.

@htuch
Copy link
Member

htuch commented Jul 24, 2017

Can you add a section to bazel/README.md on how to setup the env and do a heap check?

@mattklein123 mattklein123 merged commit b1e139b into envoyproxy:master Jul 24, 2017
@mrice32 mrice32 deleted the heap_check_fix branch July 24, 2017 19:32
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: in general java String usage accross the JNI layer is precarious. Reverting usage back to ByteBuffer.
Risk Level: low
Testing: tested with modified dispatcher code in example app that accessed the installed string accessor in MainActivity.kt

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: in general java String usage accross the JNI layer is precarious. Reverting usage back to ByteBuffer.
Risk Level: low
Testing: tested with modified dispatcher code in example app that accessed the installed string accessor in MainActivity.kt

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
mathetake pushed a commit that referenced this pull request Mar 3, 2026
**Description**

Before, there was no feedback at all unless you turn on `--debug`.
Choosing what to enable is difficult as the EG layer creates known
errors that confuse, and our layer we log too much debug as info.

This buys time by making a simple status message and verifying it in
tests.

.e.g.
```bash
$ out/aigw-darwin-arm64 run --mcp-json '{
  "mcpServers": {
    "kiwi": {
      "type": "http",
      "url": "https://mcp.kiwi.com"
    }
  }
}'
Envoy AI Gateway listening on http://localhost:1975 (admin http://localhost:51333) after 16.8s
```

Note, it most importantly only shows when (significantly later) envoy is
actually ready. If you send requests before this, it will fail. Future
PRs can improve logging.


**Related Issues/PRs (if applicable)**

Fixes #1304

---------

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gperftools doesn't seem to be detecting leaks

4 participants