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

jmeter crahes when using openjdk bundled with the brew formula #150824

Closed
4 tasks done
sandrodz opened this issue Oct 13, 2023 · 22 comments
Closed
4 tasks done

jmeter crahes when using openjdk bundled with the brew formula #150824

sandrodz opened this issue Oct 13, 2023 · 22 comments
Labels
14-arm64 Sonoma arm64 is specifically affected 14 Sonoma is specifically affected bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age

Comments

@sandrodz
Copy link

sandrodz commented Oct 13, 2023

brew gist-logs <formula> link OR brew config AND brew doctor output

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed kegs have no formulae!
This means they were either deleted or installed manually.
You should find replacements for the following formulae:
  aws-sam-cli

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  docker-completion

HOMEBREW_VERSION: 4.1.15
ORIGIN: https://github.com/Homebrew/brew
HEAD: e57a87cfe9c15f192cd4fc6695a2b3b7acf0ddf7
Last commit: 3 days ago
Core tap JSON: 12 Oct 19:22 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: vim
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 15.0.0 build 1500
Git: 2.42.0 => /opt/homebrew/bin/git
Curl: 8.1.2 => /usr/bin/curl
macOS: 14.0-arm64
CLT: 15.0.0.0.1.1694021235
Xcode: 15.0
Rosetta 2: false

Verification

  • My "brew doctor output" says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

Use jmeter, but it crashes on start on Mac m1.

Related issue: apache/jmeter#6083 (comment)

To fix jmeter crash, edit: /opt/homebrew/Cellar/jmeter/5.6.2/bin/jmeter

Changing this:

#!/bin/bash
JAVA_HOME="/opt/homebrew/opt/openjdk@17" exec "/opt/homebrew/Cellar/jmeter/5.6.2/libexec/bin/jmeter" "$@"

to this:

#!/bin/bash
exec "/opt/homebrew/Cellar/jmeter/5.6.2/libexec/bin/jmeter" "$@"

It will use my configured JDK instead of provided by Homebrew and it will not crash.

I think version that is linked by home-brew is not compatible.

What happened (include all command output)?

jmeter failed to launch, jmeter crashes

What did you expect to happen?

jmeter to launch

Step-by-step reproduction instructions (by running brew commands)

brew install jmeter && jmeter
@sandrodz sandrodz added the bug Reproducible Homebrew/homebrew-core bug label Oct 13, 2023
@Palayoub
Copy link

Palayoub commented Oct 14, 2023

I got the same behaviour, thank your for pointing this out.

doing:
$(brew --prefix openjdk)/bin/java --version
outputs:

openjdk 21 2023-09-19
OpenJDK Runtime Environment Homebrew (build 21)

but when installing jmeter with brew: brew install jmeter it downloads and installs the openjdk17.

I edited the /opt/homebrew/Cellar/jmeter/5.6.2/bin/jmeter to point to my already installed jdk21 and it works.

@cho-m
Copy link
Member

cho-m commented Oct 19, 2023

From data points, it sounds like Homebrew's openjdk@17 on Sonoma (w/ bottle built on Sonoma machine) is having issues.

I can reproduce issue. I have also confirmed that installing Ventura openjdk@17 bottle works and using Sonoma openjdk bottle works.

So, it looks like something went wrong building openjdk@17 bottle on Sonoma. May need to find out what difference is.

@cho-m
Copy link
Member

cho-m commented Oct 19, 2023

Looks like reports are a bit mixed for openjdk 21 and some people have reported issues for other tools like VisualVM (oracle/visualvm#528).

Not sure if anyone else has data points for OpenJDK built on macOS 14 Sonoma. I think most other distributions build on older macOS given common runners don't even support Sonoma (e.g. GitHub/Azure macos-latest is macOS 12 Monterey).

@Bo98
Copy link
Member

Bo98 commented Oct 23, 2023

This is a bug on Apple's part. OpenJDK relies on a framework shipped with macOS called JavaRuntimeSupport. It appears this framework triggers behaviour that causes this crash.

The reason you don't see this crash on other OpenJDK builds is because the crash is programmed to only happen when the program was built against the macOS 14 SDK. Many vendors haven't updated their build systems yet and distribute one macOS build. We distribute several macOS builds per OS version built with the corresponding SDK, so we would naturally be the first one hit by this issue.

@sandrodz
Copy link
Author

@Bo98 can someone report this to Apple?

@Bo98
Copy link
Member

Bo98 commented Oct 23, 2023

Done so as FB13297978

@Bo98
Copy link
Member

Bo98 commented Oct 23, 2023

For now, what we might do is remove Sonoma bottles from OpenJDK. To do that, we will however need to come up with a minimal reproducible code that triggers the crash that we could add to our OpenJDK test. I don't have Sonoma-compatible hardware so I'm unable to do this currently.

It might be as simple as opening a AWT window. Or maybe it'll need that + a couple things added to the menu bar.

@tsmock
Copy link

tsmock commented Nov 2, 2023

It needs to have something added to the menu bar. Oddly enough, https://download.java.net/java/GA/jdk21.0.1/415e3f918a1f4062a0074a2794853d0d/12/GPL/openjdk-21.0.1_macos-x64_bin.tar.gz works.

import javax.swing.*;
public class Test {
    public static void main(String... args) throws Exception {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        JFrame frame = new JFrame("Test Frame"); 
        JMenuBar menuBar = new JMenuBar();
        JMenu menu = new JMenu();
        JPanel panel = new JPanel();
        panel.add(new JLabel("Test"));
        frame.setJMenuBar(menuBar);
        menuBar.add(menu);
        frame.add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}

@Firefishy
Copy link
Contributor

Firefishy commented Nov 3, 2023

Also had the same crash with JOSM and the homebrew OpenJDK on Apple Silicon.

@karlvr
Copy link
Contributor

karlvr commented Nov 6, 2023

For anyone suffering with their own app, finds this issue, and who wants a quick and probably temporary fix, dropping this code into some JNI removes the problematic method from JRSMenu seemingly without any ill effects:

#import <objc/runtime.h>

@interface JRSMenu
- (void)installCarbonEventHandlers:(NSNotification *)notification;
@end

void fixJavaRuntimeSupport() {
    Class jrsMenuClass = NSClassFromString(@"JRSMenu");
    if (jrsMenuClass) {
        Method originalMethod = class_getInstanceMethod(jrsMenuClass, @selector(installCarbonEventHandlers:));
        if (originalMethod) {
            IMP newImp = imp_implementationWithBlock(^(NSNotification *notification) {
                //            NSLog(@"Ignoring notification %@", notification);
            });
            class_replaceMethod(jrsMenuClass, @selector(installCarbonEventHandlers:), newImp, method_getTypeEncoding(originalMethod));
        }
    }
}

@Cnly
Copy link

Cnly commented Nov 9, 2023

Not sure if it's the same issue, but on my macOS 14.1 Ghidra constantly crashes with Homebrew's openjdk 21.0.1 2023-10-17. IIRC this started only after I upgraded the openjdk formulae a few days ago. Using the build with the same version number from jdk.java.net fixes the problem.

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Nov 30, 2023
@liningpan
Copy link

I don't think this problem is resolved yet. I recently ran into this issue with plantuml.

@github-actions github-actions bot removed the stale No recent activity label Dec 1, 2023
@harischandraprasad
Copy link

harischandraprasad commented Dec 9, 2023

I still have this issue with Mac Book Pro with Intel Chipset with Sonoma 14.1.2.

Error:

SIGILL (0x4) at pc=0x00007ff815f6dbc5, pid=98817, tid=259
JRE version: OpenJDK Runtime Environment Homebrew (21.0.1) (build 21.0.1)
Java VM: OpenJDK 64-Bit Server VM Homebrew (21.0.1, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-amd64)
Problematic frame:
C  [AppKit+0xc92bc5]  _NSCarbonMenuCrashIfNeeded+0x258

I did remove JMeter and installed a fresh and the latest(5.6.2) still has the same issue. And also I changed JMeter start script to use the JDK 21 by updating the script:

#!/bin/bash
exec "/opt/homebrew/Cellar/jmeter/5.6.2/libexec/bin/jmeter" "$@"

Please let me know if I need to capture any specific data to post here that will help.

@mirraj2
Copy link

mirraj2 commented Dec 17, 2023

I also had this issue with JVisualVM

@wudi
Copy link

wudi commented Dec 25, 2023

+1

(base) ➜  tmp $(brew --prefix openjdk)/bin/java --version
openjdk 21.0.1 2023-10-17
OpenJDK Runtime Environment Homebrew (build 21.0.1)
OpenJDK 64-Bit Server VM Homebrew (build 21.0.1, mixed mode, sharing)
(base) ➜  tmp
(base) ➜  tmp
(base) ➜  tmp jmeter
WARNING: package sun.awt.X11 not in java.desktop
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
2023-12-25 13:59:44.629 java[95550:25430921] WARNING: Secure coding is automatically enabled for restorable state! However, not on all supported macOS versions of this application. Opt-in to secure coding explicitly by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState:.
================================================================================
Don't use GUI mode for load testing !, only for Test creation and Test debugging.
For load testing, use CLI Mode (was NON GUI):
   jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]
& increase Java Heap to meet your test requirements:
   Modify current env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m" in the jmeter batch file
Check : https://jmeter.apache.org/usermanual/best-practices.html
================================================================================
/opt/homebrew/Cellar/jmeter/5.6.2/libexec/bin/jmeter: line 199: 95550 Trace/BPT trap: 5       "$JAVA_HOME/bin/java" $ARGS $JVM_ARGS $JMETER_OPTS -jar "$PRGDIR/ApacheJMeter.jar" "$@"
(base) ➜  tmp

@melicerte
Copy link

I got the same behaviour, thank your for pointing this out.

doing: $(brew --prefix openjdk)/bin/java --version outputs:

openjdk 21 2023-09-19
OpenJDK Runtime Environment Homebrew (build 21)

but when installing jmeter with brew: brew install jmeter it downloads and installs the openjdk17.

I edited the /opt/homebrew/Cellar/jmeter/5.6.2/bin/jmeter to point to my already installed jdk21 and it works.

A full example would be nice :)

@MFurkanBabur
Copy link

I'm having the same problem and I couldn't solve it. When I solve it, I will write the result here.

@jrgrez
Copy link

jrgrez commented Jan 5, 2024

I'm having the same problem here

@cho-m
Copy link
Member

cho-m commented Jan 26, 2024

Done so as FB13297978

@Bo98, do you know if this was fixed?

On OpenJDK side, there was a mention that this may have been included with macOS 14.2 - https://bugs.openjdk.org/browse/JDK-8319420. I don't think we rebuilt OpenJDK bottles since, but there are some open PRs that should allow us to rebuild with newer SDK.

EDIT: Tested local rebuild and it seems to work.

@cho-m cho-m mentioned this issue Jan 26, 2024
1 task
@cho-m
Copy link
Member

cho-m commented Jan 27, 2024

openjdk (21) is now built using newer macOS SDK (from Xcode 15.1).

For other JDKs, users may need to wait on open PRs (or we can try triggering a rebuild job if any PR gets stalled):

@cho-m cho-m added the 14 Sonoma is specifically affected label Jan 27, 2024
@cho-m cho-m added the 14-arm64 Sonoma arm64 is specifically affected label Jan 27, 2024
@Bo98
Copy link
Member

Bo98 commented Jan 28, 2024

@Bo98, do you know if this was fixed?

Bug report with Apple is still open, but they may have forgotten to update it.

It does seem indeed fixed in macOS 14.2 - an exception to the crash has been added for JRSMenu. It should be a runtime change and thus not require rebuilds.

Screenshot 2024-01-28 at 03 59 17

For everyone following this issue: please update to macOS 14.2 and avoid 14.0 and 14.1.

Note: you may still see a warning logged to stdout. This is expected behaviour.

@Bo98 Bo98 closed this as completed Jan 28, 2024
@github-actions github-actions bot added the outdated PR was locked due to age label Feb 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
14-arm64 Sonoma arm64 is specifically affected 14 Sonoma is specifically affected bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age
Projects
None yet
Development

No branches or pull requests