GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Build and run tests on Alpine by fandreuz · Pull Request #1226 · async-profiler/async-profiler

Conversation

@fandreuz

@fandreuz fandreuz commented Apr 11, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

In this PR I add a new Alpine build/test target.

Related issues

Fixes #1136

Motivation and context

Find musl-specific issues early.

How has this been tested?

GHA


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
fandreuz and others added 11 commits April 1, 2025 21:57
@fandreuz
wait warmup
a4552ba
@fandreuz
cc
7e24191
@fandreuz
move to tests
60efdd6
@fandreuz
cc
9645d58
Francesco Andreuzzi
run on alpine
4f64bdd
Francesco Andreuzzi
fix runner name
0fbf320
Francesco Andreuzzi
setup
96a2cc7
Francesco Andreuzzi
if
e37246c
Francesco Andreuzzi
fix lib name
fcbed4c
Francesco Andreuzzi
install jdk
a1378b2
Francesco Andreuzzi
install openjdk
3c76f65
@fandreuz

fandreuz commented Apr 11, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Async-Profiler complains about missing debug symbols: Install JVM debug symbols to improve profile accuracy

Can we base the new target on zulu-openjdk-alpine? It seems that people are already using AP on that image: zulu-openjdk/zulu-openjdk#76

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@apangin

apangin commented Apr 11, 2025

Copy link
Copy Markdown
Collaborator

Why not Corretto then? It also has Alpine images

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fandreuz
corretto alpine
68fbaeb
@fandreuz

fandreuz commented Apr 11, 2025

Copy link
Copy Markdown
Contributor Author

Why not Corretto then? It also has Alpine images

Missed that, thanks

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fandreuz added 4 commits April 11, 2025 10:19
@fandreuz
missing name
30cef77
@fandreuz
ops check
81a2987
@fandreuz
nn
d16620a
@fandreuz
comment
fa61bbe
@fandreuz

fandreuz commented Apr 11, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author
/async-profiler # grep test.nativemem.Native.malloc output.txt
test/nativemem/CallsMallocCalloc.main;test/nativemem/Native.malloc;Java_test_nativemem_Native_malloc;malloc_hook 9999965

/async-profiler # grep test.nativemem.Native.calloc output.txt
test/nativemem/CallsMallocCalloc.main;test/nativemem/Native.calloc;calloc;malloc_hook 10000735

Java_test_nativemem_Native_calloc is missing in the traces for calloc events. It seems that on Alpine StackWalker::walkFp does not properly jump from calloc to the previous stack frame:

(gdb) bt
#0  StackWalker::walkFP (ucontext=0x0, callchain=0x7f57fa22aeb0, max_depth=128, java_ctx=0x7f57fa22b360) at src/stackWalker.cpp:103
#1  0x00007f57fa0218c5 in Profiler::getNativeTrace (this=0x7f57f9fc4330, ucontext=0x0, frames=0x7f57914a1160, event_type=MALLOC_SAMPLE, tid=607, java_ctx=0x7f57fa22b360) at src/profiler.cpp:341
#2  0x00007f57fa022d3a in Profiler::recordSample (this=0x7f57f9fc4330, ucontext=0x0, counter=2000147, event_type=MALLOC_SAMPLE, event=0x7f57fa22b3a0) at src/profiler.cpp:655
#3  0x00007f57fa01c4ea in MallocTracer::recordMalloc (address=0x7f57904ea170, size=2000147) at src/mallocTracer.cpp:160
#4  0x00007f57fa01bfa0 in malloc_hook (size=2000147) at src/mallocTracer.cpp:52
#5  0x00007f57fb582ee0 in calloc (m=<optimized out>, n=2000147) at src/malloc/calloc.c:40
#6  0x00007f57910b520a in Java_test_nativemem_Native_calloc () from /async-profiler/build/test/lib/libjnimalloc.so
#7  0x00007f57e01cda10 in ?? ()
#8  0x00007f57906d30c0 in ?? ()
#9  0x0000000000000000 in ?? ()

(gdb) print pc
$27 = (const void *) 0x7f57fb582ee0 <calloc+32>
(gdb) next
(gdb) print pc
$28 = (const void *) 0x7f57e01cda10

The new pc points to the instruction just before Java_test_nativemem_Native_calloc in the stack trace.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@apangin

apangin commented Apr 11, 2025

Copy link
Copy Markdown
Collaborator

Right, it seems that Alpine libc in this image does not preserve frame pointers, but even worse, it does not include DWARF unwinding info either. I see the following options:

  • Switch to cstack=dwarf and install debuginfo package that includes dwarf unwind info.
  • Find another Alpine image where libc is compiled with frame pointers and/or dwarf unwind info.
  • Modify test to look for different frames.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fandreuz

fandreuz commented Apr 12, 2025

Copy link
Copy Markdown
Contributor Author

Right, it seems that Alpine libc in this image does not preserve frame pointers, but even worse, it does not include DWARF unwinding info either. I see the following options:

  • Switch to cstack=dwarf and install debuginfo package that includes dwarf unwind info.
  • Find another Alpine image where libc is compiled with frame pointers and/or dwarf unwind info.
  • Modify test to look for different frames.

I noticed that the following change:

diff --git a/src/mallocTracer.cpp b/src/mallocTracer.cpp
index a7d0724..9082754 100644
--- a/src/mallocTracer.cpp
+++ b/src/mallocTracer.cpp
@@ -56,7 +56,7 @@ extern "C" void* malloc_hook(size_t size) {
 
 extern "C" void* calloc_hook(size_t num, size_t size) {
     void* ret = _orig_calloc(num, size);
-    if (MallocTracer::running() && ret && num && size) {
+    if (!OS::isMusl() && MallocTracer::running() && ret && num && size) {
         MallocTracer::recordMalloc(ret, num * size);
     }
     return ret;
@@ -140,11 +140,11 @@ void MallocTracer::patchLibraries() {
         cc->patchImport(im_realloc, (void*)realloc_hook);
         cc->patchImport(im_free, (void*)free_hook);
         cc->patchImport(im_aligned_alloc, (void*)aligned_alloc_hook);
+        cc->patchImport(im_calloc, (void*)calloc_hook);
 
         if (!OS::isMusl()) {
             // On musl, calloc() calls malloc() internally, and posix_memalign() calls aligned_alloc().
             // Skip the following hooks to prevent double-accounting.
-            cc->patchImport(im_calloc, (void*)calloc_hook);
             cc->patchImport(im_posix_memalign, (void*)posix_memalign_hook);
         }
     }

fixes the problem:

/async-profiler # grep test.nativemem.Native.calloc x.txt
test/nativemem/CallsMallocCalloc.main;test/nativemem/Native.calloc;Java_test_nativemem_Native_calloc;calloc;malloc_hook 10000735

but I can't understand why.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@apangin

apangin commented Apr 12, 2025

Copy link
Copy Markdown
Collaborator

This is because calloc_hook frame (which is a part of async-profiler and is compiled with frame pointers) saves frame pointer of the caller - Java_test_nativemem_Native_calloc. Without calloc_hook, calloc is called directly, and there is no frame link between Java_test_nativemem_Native_calloc and calloc.

fandreuz reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fandreuz

fandreuz commented Apr 14, 2025

Copy link
Copy Markdown
Contributor Author

This is because calloc_hook frame (which is a part of async-profiler and is compiled with frame pointers) saves frame pointer of the caller - Java_test_nativemem_Native_calloc. Without calloc_hook, calloc is called directly, and there is no frame link between Java_test_nativemem_Native_calloc and calloc.

I see, thanks. Could this also be a solution? We could have two different versions of calloc_hook, a dummy musl-specific one, and one for the other cases.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@apangin

apangin commented Apr 14, 2025

Copy link
Copy Markdown
Collaborator

Sounds interesting. This may be a simple and effective way to solve the problem.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fandreuz and others added 4 commits April 14, 2025 13:51
@fandreuz
add dummy hooks
bbe867b
Francesco Andreuzzi
no op sib calls
c4d37e0
Francesco Andreuzzi
alpine non-null dlerror
62df2c7
Francesco Andreuzzi
Merge branch 'master' into 1136-run-on-alpine
dbdf54f
@fandreuz fandreuz mentioned this pull request Apr 16, 2025
Fix musl-specific problems #1235
Merged
fandreuz added 5 commits April 23, 2025 11:29
@fandreuz
add gcovr
0e53bf3
@fandreuz
move up
aa6f042
@fandreuz
Merge branch 'fix-1243-alpine' into 1136-run-on-alpine
054d89d
@fandreuz
fix the problem in asprof
f5ae5ce
@fandreuz
Merge branch 'fix-1243-alpine' into 1136-run-on-alpine
284e264
@krk

krk commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

please ping here when prerequisite PRs are merged.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fandreuz added 5 commits April 25, 2025 15:30
@fandreuz
Merge branch 'master' into 1136-run-on-alpine
9ad44e9
@fandreuz
no set
9a2d950
@fandreuz
Revert "no set"
28d3a1c
This reverts commit 9a2d950.
@fandreuz
add bash
e4a6bf1
@fandreuz
add missing stuff
9f1dc14
@fandreuz

fandreuz commented Apr 25, 2025

Copy link
Copy Markdown
Contributor Author

We're only missing #1254 here

krk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fandreuz added 7 commits April 28, 2025 14:23
@fandreuz
Merge branch 'master' into fix-1243-alpine
2ac2b8c
@fandreuz
revert
1b776ce
@fandreuz
fix
aa699ff
@fandreuz
Merge branch 'fix-1243-alpine' into 1136-run-on-alpine
fe85e8c
@fandreuz
use docker
1a2c923
@fandreuz
alpine
bd15229
@fandreuz
add missing comment
f36eed2
apangin
apangin reviewed Apr 28, 2025
View reviewed changes
Comment thread .github/workflows/test-and-publish-nightly.yml Outdated
make COMMIT_TAG=${GITHUB_SHA:0:7} FAT_BINARY=true release coverage -j
;;
alpine*)
make COMMIT_TAG=$HASH release coverage -j

@apangin apangin Apr 28, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Why is $HASH for this case and ${GITHUB_SHA:0:7} for other?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fandreuz fandreuz Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

git merge troubles, fixed in 4618514

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
fandreuz added 3 commits April 28, 2025 15:05
@fandreuz
fix
4618514
@fandreuz
Merge branch 'master' into 1136-run-on-alpine
cf57004
@fandreuz
trigger
5706bf0
apangin
apangin reviewed Apr 28, 2025
View reviewed changes
Comment thread .github/workflows/test-and-publish-nightly.yml
java-version: 11
java-distribution: corretto
image: "public.ecr.aws/async-profiler/asprof-builder-arm:latest"
image: public.ecr.aws/async-profiler/asprof-builder-arm:latest

@apangin apangin Apr 28, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

On Alpine, we need to test binaries that were built on Debian.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fandreuz fandreuz Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

91e17e2

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread .github/workflows/test-and-publish-nightly.yml Outdated
name: ubuntu-latest
image: public.ecr.aws/async-profiler/asprof-builder-x86:latest
- runson:
display: alpine

@apangin apangin Apr 28, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Will artifacts from this build be published in a release? They should not.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fandreuz fandreuz Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I thought Alpine should have its own artifacts, fixed in 91e17e2

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@fandreuz
alpine should test debian bins
91e17e2
apangin
apangin reviewed Apr 28, 2025
View reviewed changes
Comment thread .github/workflows/test-and-publish-nightly.yml Outdated
make COMMIT_TAG=${GITHUB_SHA:0:7} FAT_BINARY=true release coverage -j
make COMMIT_TAG=$HASH FAT_BINARY=true release coverage -j
;;
alpine*)

@apangin apangin Apr 28, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If we no longer build on alpine, this case is not needed?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fandreuz fandreuz Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yes, and same for setup-java a bit above, thanks: 2cd2700

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@fandreuz
nn
2cd2700
@apangin
apangin merged commit d2c85c1 into async-profiler:master Apr 28, 2025
krk pushed a commit to krk/async-profiler that referenced this pull request May 1, 2025
@fandreuz @krk
Build and run tests on Alpine (async-profiler#1226)
8d776ed
@krk krk mentioned this pull request Sep 9, 2025
Add Liberica to the CI on Alpaquita musl #1466
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@apangin apangin apangin left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

test

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Run tests on Alpine Linux in CI

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@fandreuz @apangin @krk
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.