Opened 3 years ago

Closed 2 years ago

#62769 closed defect (fixed)

iTerm2 @ 3.4.6: Embedded iTermServer binary linked against ubsan

Reported by: gnachman (George Nachman) Owned by: markemer (Mark Anderson)
Priority: Normal Milestone:
Component: ports Version: 2.6.4
Keywords: Cc: i0ntempest, darkfishy (A A), EJFielding (Eric Fielding), ferdy (Giuseppe `ferdy` Miceli)
Port: iTerm2

Description

Please see this issue for the original user reports: https://gitlab.com/gnachman/iterm2/-/issues/9637

I can reproduce this:

  1. On macOS 10.15.7, run sudo port install iTerm2
  2. Run otool -L on iTerm.app/Contents/MacOS/iTermServer and see that ubsan is among the required dynamic libraries.

I don't know why that is the case—perhaps MacPorts is building against a target other than Deployment? The Development target does have this enabled, but that isn't intended to be used by end users. Deployment is meant for end users. If you need different settings, like disabling signing, I could possibly add a new build target.

I am not the port maintainer, just the app author and I'd like to get people up and running again.

This bug is particularly painful for users because the broken iTermServer binary is cached and won't be overwritten until they to go a new version. Users will need to manually delete ~/Library/Application Support/iTerm2/iTermServer-3.4.6 and then install a working build in order to recover.

I'm open to suggestions on how to prevent such problems in the future!

Attachments (2)

main.log (21.2 KB) - added by EJFielding (Eric Fielding) 3 years ago.
main.log
iTerm-3.4.9-debug.log (1.8 MB) - added by darkfishy (A A) 3 years ago.

Download all attachments as: .zip

Change History (30)

comment:1 Changed 3 years ago by jmroot (Joshua Root)

Owner: set to markemer
Status: newassigned

comment:2 Changed 3 years ago by jmroot (Joshua Root)

The port seems to be running make prod to build. Build log for 10.15 is here: https://build.macports.org/builders/ports-10.15_x86_64-builder/builds/56303/steps/install-port/logs/stdio

comment:3 Changed 3 years ago by jmroot (Joshua Root)

Cc: i0ntempest added

comment:4 Changed 3 years ago by i0ntempest

I don't understand everything but I've found out that patch-Makefile-XC10.diff seems to be problematic. I don't know why the port maintainer made the patch and why it causes the build to link stuff that it shouldn't in this configuration, the only thing it does seem to be changing the build directory.
After making changes to that patch both 3.4.6 and 3.3.12 (versions using this patch) build successfully and 3.4.6 actually works.
About that signing thing,codesign was disabled in this port by a MacPorts member like 2 years ago. I don't know the exact reason behind this.

comment:5 Changed 3 years ago by i0ntempest

Resolution: fixed
Status: assignedclosed

In 4b43a62994a22c90be7dd0c96d570ad42accb48d/macports-ports (master):

iTerm2: change Makefile patch to fix linking issue

Closes: #62769

comment:6 Changed 3 years ago by markemer (Mark Anderson)

Since this is named XC10 - I have to imagine it was done to fix a linking issue with Xcode 10 which at this point is 2 years old as are the whatever issues it dealt with. Thankfully, just removing it seems to work now.

comment:7 Changed 3 years ago by EJFielding (Eric Fielding)

I am not sure whether to add a comment on this ticket or create a new one. This seems likely related to the change made to the port by @i0ntempest. The new iTerm2-3.4.6_1.darwin_19 is failing to build for me on 10.15.7 and my old v3.4.5 stopped working when I installed the Apple security update.

:info:build xcodebuild -parallelizeTargets -target iTerm2 -configuration Deployment && \
:info:build 	chmod -R go+rX build/Deployment
:info:build Command line invocation:
:info:build     /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -parallelizeTargets -target iTerm2 -configuration Deployment
:info:build 2021-04-29 10:31:39.730 xcodebuild[99626:659921] Error Domain=com.apple.CoreSimulator.SimError Code=400 "Unable to determine SimDeviceSet, set_path=(null)" UserInfo={NSLocalizedDescription=Unable to determine SimDeviceSet, set_path=(null), NSUnderlyingError=0x7fe01bc2e000 {Error Domain=NSPOSIXErrorDomain Code=12 "Cannot allocate memory" UserInfo={NSLocalizedFailureReason=Allocation or initialization failed., NSLocalizedDescription=Failed to initialize simulator device set.}}}
:info:build 2021-04-29 10:31:39.731 xcodebuild[99626:659921]  iOSSimulator: [SimServiceContext defaultDeviceSetWithError:] returned nil (Error Domain=com.apple.CoreSimulator.SimError Code=400 "Failed to initialize simulator device set." UserInfo={NSLocalizedFailureReason=Failed to subscribe to notifications from CoreSimulatorService., NSLocalizedDescription=Failed to initialize simulator device set., NSUnderlyingError=0x7fe01bce8100 {Error Domain=com.apple.CoreSimulator.SimError Code=400 "Unable to determine SimDeviceSet, set_path=(null)" UserInfo={NSLocalizedDescription=Unable to determine SimDeviceSet, set_path=(null), NSUnderlyingError=0x7fe01bc2e000 {Error Domain=NSPOSIXErrorDomain Code=12 "Cannot allocate memory" UserInfo={NSLocalizedFailureReason=Allocation or initialization failed., NSLocalizedDescription=Failed to initialize simulator device set.}}}}}). Simulator device support disabled.
:info:build 2021-04-29 10:31:40.133 xcodebuild[99626:659856] [MT] IDELogStore: Failed to open log store at /opt/local/var/macports/home/Library/Developer/Xcode/DerivedData/iTerm2-fvwrlqkbbauquofcskwpyydiojon/Logs/Build
:info:build 2021-04-29 10:31:40.133 xcodebuild[99626:659856] [MT] IDELogStore: Failed to open Build log store: Error Domain=IDEFoundationErrorDomain Code=1 "Unable to create log store directory at '/opt/local/var/macports/home/Library/Developer/Xcode/DerivedData/iTerm2-fvwrlqkbbauquofcskwpyydiojon/Logs/Build': (513) You don’t have permission to save the file “Build” in the folder “Logs”." UserInfo={NSLocalizedDescription=Unable to create log store directory at '/opt/local/var/macports/home/Library/Developer/Xcode/DerivedData/iTerm2-fvwrlqkbbauquofcskwpyydiojon/Logs/Build': (513) You don’t have permission to save the file “Build” in the folder “Logs”.}. User info: {
:info:build     NSLocalizedDescription = "Unable to create log store directory at '/opt/local/var/macports/home/Library/Developer/Xcode/DerivedData/iTerm2-fvwrlqkbbauquofcskwpyydiojon/Logs/Build': (513) You don\U2019t have permission to save the file \U201cBuild\U201d in the folder \U201cLogs\U201d.";

I attached the full main.log.

Last edited 3 years ago by EJFielding (Eric Fielding) (previous) (diff)

Changed 3 years ago by EJFielding (Eric Fielding)

Attachment: main.log added

main.log

comment:8 Changed 3 years ago by i0ntempest

Welp here comes the cryptic permission error of Xcode build again.
I *could* modify the port to use Xcode pg so we bypass the Makefile completely, but first I’d like the maintainer’s opinion on this since I don’t know what effect this could have on older systems, and second I’m on vacation and won’t be at my Mac for at least 6 days.

comment:9 Changed 3 years ago by raimue (Rainer Müller)

I wouldn't be so sure that the xcode port group alone would help. This build needs to set -derivedDataPath to avoid these permission errors when building in the MacPorts environment as the default path is outside the sandbox. See #57137.

comment:10 Changed 3 years ago by i0ntempest

Okay, so now either the patch need to be back without triggering the ubsan link, or we refactor to use Xcode pg and add needed flags. I’ll experiment with both when I get back.

comment:11 Changed 3 years ago by markemer (Mark Anderson)

Maybe we need to just apply the patch when using Xcode 10?

comment:12 Changed 3 years ago by markemer (Mark Anderson)

Resolution: fixed
Status: closedreopened

Reopening as I had to revert the last change that fixed this as it broke other things.

comment:13 Changed 3 years ago by darkfishy (A A)

Cc: darkfishy added

comment:14 Changed 3 years ago by EJFielding (Eric Fielding)

Cc: EJFielding added

comment:15 Changed 3 years ago by EJFielding (Eric Fielding)

This is still broken in iTerm2 @3.4.8_0 (active)

otool -L /Applications/MacPorts/iTerm2.app/Contents/MacOS/iTermServer
/Applications/MacPorts/iTerm2.app/Contents/MacOS/iTermServer:
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 52.0.0)
	@rpath/libclang_rt.ubsan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
Last edited 3 years ago by EJFielding (Eric Fielding) (previous) (diff)

comment:16 Changed 3 years ago by darkfishy (A A)

This issue is persistent in iTerm2 @3.4.9_0 on macOS 10.15.7 and same crashing behaviour on start.

$ otool -L /Applications/MacPorts/iTerm2.app/Contents/MacOS/iTermServer
/Applications/MacPorts/iTerm2.app/Contents/MacOS/iTermServer:
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 52.0.0)
	@rpath/libclang_rt.ubsan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

and

$ otool -L /Applications/MacPorts/iTerm2.app/Contents/MacOS/iTerm2
/Applications/MacPorts/iTerm2.app/Contents/MacOS/iTerm2:
	/usr/lib/libaprutil-1.0.dylib (compatibility version 4.0.0, current version 4.0.0)
	/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 64.2.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)
	@rpath/BetterFontPicker.framework/Versions/A/BetterFontPicker (compatibility version 1.0.0, current version 1.0.0)
	@rpath/SearchableComboListView.framework/Versions/A/SearchableComboListView (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory (compatibility version 1.0.0, current version 1.0.0)
	@executable_path/../Frameworks/NMSSH.framework/Versions/A/NMSSH (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 59306.140.5)
	/System/Library/Frameworks/ScriptingBridge.framework/Versions/A/ScriptingBridge (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1894.60.100)
	@rpath/ColorPicker.framework/Versions/A/ColorPicker (compatibility version 1.0.0, current version 1.0.0)
	@rpath/CoreParse.framework/Versions/A/CoreParse (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 162.0.0)
	@rpath/Sparkle.framework/Versions/A/Sparkle (compatibility version 1.6.0, current version 1.22.0)
	/System/Library/Frameworks/Quartz.framework/Versions/A/Quartz (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1677.104.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	@rpath/libclang_rt.ubsan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 52.0.0)
	/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData (compatibility version 1.0.0, current version 977.3.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1677.104.0)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1355.22.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1069.24.0)
	/System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/LocalAuthentication.framework/Versions/A/LocalAuthentication (compatibility version 1.0.0, current version 693.140.3)
	/System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 212.8.0)
	/System/Library/Frameworks/MetalKit.framework/Versions/A/MetalKit (compatibility version 1.0.0, current version 141.2.0)
	/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
	/System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 609.3.5)
	/usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 308.5.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)

Changed 3 years ago by darkfishy (A A)

Attachment: iTerm-3.4.9-debug.log added

comment:17 Changed 2 years ago by ferdy (Giuseppe `ferdy` Miceli)

Cc: ferdy added

comment:18 Changed 2 years ago by ferdy (Giuseppe `ferdy` Miceli)

this should be fixed now - see comment:ticket:63542:6

Last edited 2 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:19 Changed 2 years ago by darkfishy (A A)

Confirmed. iTerm2 @3.4.12 works on macOS 10.15.7

comment:20 Changed 2 years ago by i0ntempest

Resolution: fixed
Status: reopenedclosed

Marking as resolved as fixed in the new version.

comment:21 Changed 2 years ago by EJFielding (Eric Fielding)

This bug has returned in iTerm2 @3.4.13_0. I had a recent version running well, but then I ran the MacPorts migration procedure after upgrading to MacOS 11.6. It seems that this updated to the new 3.4.13 and all my iTerm2 windows have shells that crash as soon as they open. Fortunately, I had saved a non-MacPorts version of iTerm2 installed from the website so I could login and diagnose what was happening. As before, the MacPorts installation has installed a version of the iTermServer in the Application Support folder that links to ubsan.

otool -L ~/Library/Application\ Support/iTerm2/iTermServer-3.4.13
/Users/fielding/Library/Application Support/iTerm2/iTermServer-3.4.13:
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 54.0.0)
	@rpath/libclang_rt.ubsan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5)

comment:22 Changed 2 years ago by EJFielding (Eric Fielding)

I checked the version of iTermServer in the application is correctly linked:

otool -L /Applications/iTerm.app/Contents/MacOS/iTermServer
/Applications/iTerm.app/Contents/MacOS/iTermServer:
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 54.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5)

I tried copying that to my Application Support folder, but it was overwritten with the bad version again when I tried to launch iTerm2 from MacPorts.

comment:23 Changed 2 years ago by markemer (Mark Anderson)

Resolution: fixed
Status: closedreopened

This has apparently resurfaced. It's strange since it disappeared and is back.

comment:24 Changed 2 years ago by ryandesign (Ryan Carsten Schmidt)

Because of this problem, the developers of iTerm2 are recommend users not install iTerm2 using MacPorts. Please fix this and then inform the developers that it's fixed so that they can stop badmouthing MacPorts.

comment:25 Changed 2 years ago by i0ntempest

I'm giving another shot at this by refactoring to Xcode PG. PR will be opened soon and I'll need people with different OS versions to test it.

comment:27 Changed 2 years ago by i0ntempest

Specifying -derivedDataPath ./DerivedData will trigger the link to ubsan, not specifying it will lead to permission errors (for 3.4.14). Out of idea.

Last edited 2 years ago by i0ntempest (previous) (diff)

comment:28 Changed 2 years ago by i0ntempest

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.