Menu

#1165 Unicode installers fail to build on macOS

3.0 Series
open
nobody
None
5
2021-07-26
2016-12-01
idleberg
No

All installers that contain the Unicode true will fail to build using makensis 3.0 on macOS.

Consider this minimal example:

Unicode true
OutFile "demo.exe"

Section
SectionEnd

This will result in the following error message:

Processing script file: "/tmp/unicode.nsi" (UTF8)

Processed 1 file, writing output (x86-unicode):
libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
[Finished in 0.0s with exit code -6]

Discussion

  • Emmet McPoland

    Emmet McPoland - 2016-12-12

    Ran into this issue myself. https://github.com/electron-userland/electron-builder/issues/503#issuecomment-266466859

    I discovered it when I was building via Jenkins, when I SSH'd onto the machine and built it, there was no issue. However Jenkins hadnt correctly inherited the systems defsault encoding and was using ASCII. This caused the issue.

    Workaround is provided in the link.

     
    • idleberg

      idleberg - 2021-03-30

      I've built the Homebrew formula for makensis with those environment variables set, but the problem persists. I'm wondering why the MacPorts version compiles the script just fine.

       
  • Geoffrey Sutcliffe

    Hi folks!

    I am getting this error. Here's the output log with -V4, and the script is attached ...

    MakeNSIS v3.06.1 - Copyright 1999-2020 Contributors
    See the file COPYING for license details.
    Credits can be found in the Users Manual.

    Command line defined: "MAVersion=1.305"
    Command line defined: "CompiledSource=/Users/geoff/Documents/MyDocuments/Development/GitSpace/ModelAccuracy/build/tmp/preCreateInstaller"
    Changing directory to: "/Users/geoff/Documents/MyDocuments/Development/GitSpace/ModelAccuracy/installer"

    Processing script file: "ModelAccuracy.nsi" (UTF8)
    Processing default plugins: "/usr/local/share/nsis/Plugins/x86-ansi/*.dll"

    • AdvSplash::show
    • Banner::destroy
    • Banner::getWindow
    • Banner::show
    • BgImage::AddImage
    • BgImage::AddText
    • BgImage::Clear
    • BgImage::Destroy
    • BgImage::Redraw
    • BgImage::SetBg
    • BgImage::SetReturn
    • BgImage::Sound
    • Dialer::AttemptConnect
    • Dialer::AutodialHangup
    • Dialer::AutodialOnline
    • Dialer::AutodialUnattended
    • Dialer::GetConnectedState
    • InstallOptions::dialog
    • InstallOptions::initDialog
    • InstallOptions::show
    • LangDLL::LangDialog
    • Math::Script
    • NSISdl::download
    • NSISdl::download_quiet
    • Splash::show
    • StartMenu::Init
    • StartMenu::Select
    • StartMenu::Show
    • System::Alloc
    • System::Call
    • System::Copy
    • System::Free
    • System::Get
    • System::Int64Op
    • System::Store
    • System::StrAlloc
    • TypeLib::GetLibVersion
    • TypeLib::Register
    • TypeLib::UnRegister
    • UserInfo::GetAccountType
    • UserInfo::GetName
    • UserInfo::GetOriginalAccountType
    • VPatch::GetFileCRC32
    • VPatch::GetFileMD5
    • VPatch::vpatchfile
    • nsDialogs::Create
    • nsDialogs::CreateControl
    • nsDialogs::CreateItem
    • nsDialogs::CreateTimer
    • nsDialogs::GetUserData
    • nsDialogs::KillTimer
    • nsDialogs::OnBack
    • nsDialogs::OnChange
    • nsDialogs::OnClick
    • nsDialogs::OnNotify
    • nsDialogs::SelectFileDialog
    • nsDialogs::SelectFolderDialog
    • nsDialogs::SetRTL
    • nsDialogs::SetUserData
    • nsDialogs::Show
    • nsExec::Exec
    • nsExec::ExecToLog
    • nsExec::ExecToStack

    Unicode: true
    Processing default plugins: "/usr/local/share/nsis/Plugins/x86-unicode/*.dll"

    • AdvSplash::show
    • Banner::destroy
    • Banner::getWindow
    • Banner::show
    • BgImage::AddImage
    • BgImage::AddText
    • BgImage::Clear
    • BgImage::Destroy
    • BgImage::Redraw
    • BgImage::SetBg
    • BgImage::SetReturn
    • BgImage::Sound
    • Dialer::AttemptConnect
    • Dialer::AutodialHangup
    • Dialer::AutodialOnline
    • Dialer::AutodialUnattended
    • Dialer::GetConnectedState
    • InstallOptions::dialog
    • InstallOptions::initDialog
    • InstallOptions::make_unicode
    • InstallOptions::show
    • LangDLL::LangDialog
    • Math::Script
    • NSISdl::download
    • NSISdl::download_quiet
    • Splash::show
    • StartMenu::Init
    • StartMenu::Select
    • StartMenu::Show
    • System::Alloc
    • System::Call
    • System::Copy
    • System::Free
    • System::Get
    • System::Int64Op
    • System::Store
    • System::StrAlloc
    • TypeLib::GetLibVersion
    • TypeLib::Register
    • TypeLib::UnRegister
    • UserInfo::GetAccountType
    • UserInfo::GetName
    • UserInfo::GetOriginalAccountType
    • VPatch::GetFileCRC32
    • VPatch::GetFileMD5
    • VPatch::vpatchfile
    • nsDialogs::Create
    • nsDialogs::CreateControl
    • nsDialogs::CreateItem
    • nsDialogs::CreateTimer
    • nsDialogs::GetUserData
    • nsDialogs::KillTimer
    • nsDialogs::OnBack
    • nsDialogs::OnChange
    • nsDialogs::OnClick
    • nsDialogs::OnNotify
    • nsDialogs::SelectFileDialog
    • nsDialogs::SelectFolderDialog
    • nsDialogs::SetRTL
    • nsDialogs::SetUserData
    • nsDialogs::Show
    • nsExec::Exec
    • nsExec::ExecToLog
    • nsExec::ExecToStack

    !addplugindir: "plugins"

    • INetC::get
    • INetC::head
    • INetC::post
    • INetC::put
    • nsProcess::_CloseProcess
    • nsProcess::_FindProcess
    • nsProcess::_KillProcess
    • nsProcess::_Unload
    • nsisunz::Unzip
    • nsisunz::UnzipToLog
    • nsisunz::UnzipToStack
    • nsisunz::extract_RunDLL
      !include: "/usr/local/share/nsis/Include/MUI2.nsh" (UTF8)
      !include: "/usr/local/share/nsis/Contrib/Modern UI 2/MUI2.nsh" (UTF8)
      NSIS Modern User Interface version 2.1 - Copyright 2002-2020 Joost Verburg (/usr/local/share/nsis/Contrib/Modern UI 2/MUI2.nsh:14)
      !include: closed: "/usr/local/share/nsis/Contrib/Modern UI 2/MUI2.nsh"
      !include: closed: "/usr/local/share/nsis/Include/MUI2.nsh"
      !include: "/usr/local/share/nsis/Include/LogicLib.nsh" (UTF8)
      !include: closed: "/usr/local/share/nsis/Include/LogicLib.nsh"
      !include: "/usr/local/share/nsis/Include/x64.nsh" (UTF8)
      !define: "X64_NSH_"=""
      !include: "/usr/local/share/nsis/Include/LogicLib.nsh" (UTF8)
      !include: closed: "/usr/local/share/nsis/Include/LogicLib.nsh"
      !define: "IsWow64"=""" IsWow64 """
      !define: "RunningX64"=""" RunningX64 """
      !define: "GetNativeMachineArchitecture"="!insertmacro GetNativeMachineArchitecture "
      !define: "IsNativeMachineArchitecture"=""" IsNativeMachineArchitecture "
      !define: "IsNativeIA32"=""" IsNativeMachineArchitecture 332"
      !define: "IsNativeAMD64"=""" IsNativeMachineArchitecture 34404"
      !define: "IsNativeARM64"=""" IsNativeMachineArchitecture 43620"
      !define: "DisableX64FSRedirection"="!insertmacro DisableX64FSRedirection"
      !define: "EnableX64FSRedirection"="!insertmacro EnableX64FSRedirection"
      !include: closed: "/usr/local/share/nsis/Include/x64.nsh"
      !include: "nsProcess.nsh" (UTF8)
      !define: "nsProcess::FindProcess"="!insertmacro nsProcess::FindProcess"
      !define: "nsProcess::KillProcess"="!insertmacro nsProcess::KillProcess"
      !define: "nsProcess::CloseProcess"="!insertmacro nsProcess::CloseProcess"
      !define: "nsProcess::Unload"="!insertmacro nsProcess::Unload"
      !include: closed: "nsProcess.nsh"
      !define: "ARP"="Software\Microsoft\Windows\CurrentVersion\Uninstall\ModelAccuracy"
      Name: "ModelAccuracy"
      OutFile: "../ModelAccuracyInstall_1.305.exe"
      libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc

    I'm on a (nold, Mid 2012) MacBook Pro, macOS Cataline 10.15.5.

    A fix would be cool.

     
    • Jason

      Jason - 2020-08-29

      Comment out the "InstallDir" line and see if the problem goes away. If not, then keep commenting lines out until it does go away. The idea is to find which command causes it. I don't have any macs to test on, sorry.

       
  • Geoffrey Sutcliffe

    The problem is within makensis, so that post might help the developers of makensis get rid of this issue. Thanks for pointing it out ... how do I/you/we send it to the developers to help them?

     
    • Anders

      Anders - 2020-08-29

      I don't think any of us have Macs so please do what Jason suggests, comment out lines until it stops crashing to figure out which instruction is the cause of the problem.

       
      • idleberg

        idleberg - 2020-09-03

        I've setup a repository with GitHub Actions that compiles a minimal, reproducable example on latest macOS. This exact script does not compile on macOS under certain circumstances (see my speculations below), Interestingly, the compilation does work in that image.

        Feel free to fork it and adjust it according to your testing needs.

        https://github.com/idleberg/nsis-macos-unicode-bug

         

        Last edit: idleberg 2020-09-03
  • Geoffrey Sutcliffe

    It's as the original post explains, if I change "Unicode true" to "Unicode false" the build succeeds. Something inside makensis doesn't like "Unicode true".

    Cheers,

    Geoff

     
    • Jason

      Jason - 2020-09-03

      What if you set it to 'unicode true', then add another one that changes it back to false? Does it still fail?

      Unicode true
      Unicode false
      
       
      • idleberg

        idleberg - 2020-09-03

        This compiles without error

         
        • Jason

          Jason - 2020-09-03

          That's what I was afraid of. It's somewhere else in the code, and not the 'Unicode' command itself (I suspected that might be the case).

           
  • Jason

    Jason - 2020-09-03

    If it helps, I did a quick memory check in debug mode using valgrind on Fedora 32. Script is the same as the initial post above, I just commented out 'unicode true' to get the ansi version.

     

    Last edit: Jason 2020-09-03
  • idleberg

    idleberg - 2020-09-03

    This question might seem a bit odd, but how are you compiling your installers? I've installed several versions of makensis using Homebrew (both the official formula and third party) and MacPort. When I compile the script inside Visual Studio Code, I get the same error with any of the installed versions. However, when I compile in the shell, I don't get that error.

     
  • Geoffrey Sutcliffe

    Not sure if that question was addressed to me ... I installed makensis using homebrew, and then call it from gradle.

     
    • idleberg

      idleberg - 2020-09-04

      What happens when you run makensis from your shell, does it behave differently?

       
  • Geoffrey Sutcliffe

    Same result if I call it from the shell ...

    makensis -DMAVersion=1.304 -DCompiledSource=/Users/geoff/MyDocuments/Development/GitSpace/ModelAccuracy/bin/main ModelAccuracy.nsi
    Command line defined: "MAVersion=1.304"
    Command line defined: "CompiledSource=/Users/geoff/MyDocuments/Development/GitSpace/ModelAccuracy/bin/main"
    Processing script file: "ModelAccuracy.nsi" (UTF8)
    libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
    Abort

     
  • idleberg

    idleberg - 2021-07-07

    Coming back to this with a series of tests

    Example Script

    OutFile "file_name.exe"
    Unicode true
    
    Section ""
    SectionEnd
    

    Tests

    Homebrew

    # Update Homebrew, remove NSIS, clean-up
    $ brew update && brew remove makensis && brew clean
    
    # Install NSIS
    $ brew install makensis
    
    # Print version
    $ /usr/local/bin/makensis -VERSION
    v3.06.1
    
    # Print header info
    $ /usr/local/bin/makensis -HDRINFO
    Size of first header is 28 bytes.
    Size of main header is 300 bytes.
    Size of each section is 4120 bytes.
    Size of each page is 64 bytes.
    Size of each instruction is 28 bytes.
    
    Defined symbols: __GLOBAL__,NSIS_CHAR_SIZE=1,NSIS_COMPRESS_BZIP2_LEVEL=9,NSIS_CONFIG_COMPONENTPAGE,NSIS_CONFIG_COMPRESSION_SUPPORT,NSIS_CONFIG_CONST_DATA_PATH,NSIS_CONFIG_CRC_SUPPORT,NSIS_CONFIG_ENHANCEDUI_SUPPORT,NSIS_CONFIG_LICENSEPAGE,NSIS_CONFIG_PLUGIN_SUPPORT,NSIS_CONFIG_SILENT_SUPPORT,NSIS_CONFIG_UNINSTALL_SUPPORT,NSIS_CONFIG_VISIBLE_SUPPORT,NSIS_CPU=x86,NSIS_DEFAULT_LANG=1033,NSIS_FIX_COMMENT_HANDLING,NSIS_IX86=300,NSIS_LOCKWINDOW_SUPPORT,NSIS_MAKENSIS64,NSIS_MAX_INST_TYPES=32,NSIS_MAX_STRLEN=1024,NSIS_PACKEDVERSION=0x03005666,NSIS_PTR_SIZE=4,NSIS_SUPPORT_ACTIVEXREG,NSIS_SUPPORT_BGBG,NSIS_SUPPORT_CODECALLBACKS,NSIS_SUPPORT_COPYFILES,NSIS_SUPPORT_CREATESHORTCUT,NSIS_SUPPORT_DELETE,NSIS_SUPPORT_ENVIRONMENT,NSIS_SUPPORT_EXECUTE,NSIS_SUPPORT_FILE,NSIS_SUPPORT_FILEFUNCTIONS,NSIS_SUPPORT_FINDFIRST,NSIS_SUPPORT_FNUTIL,NSIS_SUPPORT_GETDLLVERSION,NSIS_SUPPORT_GETFILETIME,NSIS_SUPPORT_HWNDS,NSIS_SUPPORT_INIFILES,NSIS_SUPPORT_INTOPTS,NSIS_SUPPORT_LANG_IN_STRINGS,NSIS_SUPPORT_MESSAGEBOX,NSIS_SUPPORT_MOVEONREBOOT,NSIS_SUPPORT_NAMED_USERVARS,NSIS_SUPPORT_REBOOT,NSIS_SUPPORT_REGISTRYFUNCTIONS,NSIS_SUPPORT_RENAME,NSIS_SUPPORT_RMDIR,NSIS_SUPPORT_SHELLEXECUTE,NSIS_SUPPORT_STACK,NSIS_SUPPORT_STANDARD_PREDEFINES,NSIS_SUPPORT_STROPTS,NSIS_SUPPORT_VERSION_INFO,NSIS_UNICODE_MAKENSIS,NSIS_VARS_SECTION=.ndata,NSIS_VERSION=v3.06.1,NSISDIR=/usr/local/share/nsis,PREFIX_CONF=/usr/local/etc,PREFIX_DATA=/usr/local/share/nsis,PREFIX_DOC=/usr/local/Cellar/makensis/3.06.1/share/nsis/Docs
    
    # Compile example script
    $ /usr/local/bin/makensis unicode-true.nsi
    Processing script file: "unicode-true.nsi" (UTF8)
    
    Processed 1 file, writing output (x86-unicode):
    
    Output: "/Users/jan/Desktop/_NSIS/file_name.exe"
    Install: 1 page (64 bytes), 1 section (4120 bytes), 1 instruction (28 bytes), 99 strings (536 bytes), 1 language table (194 bytes).
    
    Using zlib compression.
    
    EXE header size:               37888 / 39424 bytes
    Install code:                    457 / 3286 bytes
    Install data:                      0 / 0 bytes
    CRC (0x5549BA54):                  4 / 4 bytes
    
    Total size:                    38364 / 42742 bytes (89.7%)
    

    MacPorts

    # Update MacPorts, remove NSIS (clean-up will follow!)
    $ sudo port selfupdate && sudo port uninstall nsis
    
     # Install NSIS and clean-up
    $ sudo /opt/local/bin/port install -c nsis
    
    # Print version
    $ /opt/local/bin/makensis -VERSION
    v3.06.1
    
    # Print header info
    $ /opt/local/bin/makensis -HDRINFO
    Size of first header is 28 bytes.
    Size of main header is 300 bytes.
    Size of each section is 4120 bytes.
    Size of each page is 64 bytes.
    Size of each instruction is 28 bytes.
    
    Defined symbols: __GLOBAL__,NSIS_CHAR_SIZE=1,NSIS_COMPRESS_BZIP2_LEVEL=9,NSIS_CONFIG_COMPONENTPAGE,NSIS_CONFIG_COMPRESSION_SUPPORT,NSIS_CONFIG_CONST_DATA_PATH,NSIS_CONFIG_CRC_SUPPORT,NSIS_CONFIG_ENHANCEDUI_SUPPORT,NSIS_CONFIG_LICENSEPAGE,NSIS_CONFIG_PLUGIN_SUPPORT,NSIS_CONFIG_SILENT_SUPPORT,NSIS_CONFIG_UNINSTALL_SUPPORT,NSIS_CONFIG_VISIBLE_SUPPORT,NSIS_CPU=x86,NSIS_DEFAULT_LANG=1033,NSIS_FIX_COMMENT_HANDLING,NSIS_IX86=300,NSIS_LOCKWINDOW_SUPPORT,NSIS_MAKENSIS64,NSIS_MAX_INST_TYPES=32,NSIS_MAX_STRLEN=1024,NSIS_PACKEDVERSION=0x03005666,NSIS_PTR_SIZE=4,NSIS_SUPPORT_ACTIVEXREG,NSIS_SUPPORT_BGBG,NSIS_SUPPORT_CODECALLBACKS,NSIS_SUPPORT_COPYFILES,NSIS_SUPPORT_CREATESHORTCUT,NSIS_SUPPORT_DELETE,NSIS_SUPPORT_ENVIRONMENT,NSIS_SUPPORT_EXECUTE,NSIS_SUPPORT_FILE,NSIS_SUPPORT_FILEFUNCTIONS,NSIS_SUPPORT_FINDFIRST,NSIS_SUPPORT_FNUTIL,NSIS_SUPPORT_GETDLLVERSION,NSIS_SUPPORT_GETFILETIME,NSIS_SUPPORT_HWNDS,NSIS_SUPPORT_INIFILES,NSIS_SUPPORT_INTOPTS,NSIS_SUPPORT_LANG_IN_STRINGS,NSIS_SUPPORT_MESSAGEBOX,NSIS_SUPPORT_MOVEONREBOOT,NSIS_SUPPORT_NAMED_USERVARS,NSIS_SUPPORT_REBOOT,NSIS_SUPPORT_REGISTRYFUNCTIONS,NSIS_SUPPORT_RENAME,NSIS_SUPPORT_RMDIR,NSIS_SUPPORT_SHELLEXECUTE,NSIS_SUPPORT_STACK,NSIS_SUPPORT_STANDARD_PREDEFINES,NSIS_SUPPORT_STROPTS,NSIS_SUPPORT_VERSION_INFO,NSIS_UNICODE_MAKENSIS,NSIS_VARS_SECTION=.ndata,NSIS_VERSION=v3.06.1,NSISDIR=/opt/local/share/nsis,PREFIX_CONF=/opt/local/etc,PREFIX_DATA=/opt/local/share/nsis,PREFIX_DOC=/opt/local/share/doc/nsis
    
    # Compile example script
    $ /opt/local/bin/makensis unicode-true.nsi 
    Processing config: /opt/local/etc/nsisconf.nsh
    Processing script file: "unicode-true.nsi" (UTF8)
    
    Processed 1 file, writing output (x86-unicode):
    
    Output: "/Users/jan/Desktop/_NSIS/file_name.exe"
    Install: 1 page (64 bytes), 1 section (4120 bytes), 1 instruction (28 bytes), 99 strings (536 bytes), 1 language table (194 bytes).
    
    Using zlib compression.
    
    EXE header size:               37888 / 39424 bytes
    Install code:                    457 / 3286 bytes
    Install data:                      0 / 0 bytes
    CRC (0x5549BA54):                  4 / 4 bytes
    
    Total size:                    38349 / 42714 bytes (89.7%)
    

    Code Editors

    When I compile the same script using both, Homebrew and MacPorts, versions of makensis, I'm getting problems.

    Visual Studio Code v1.57.1 & Atom v1.57.0

    Using a build plugin, the script fails building in both editors

    Processing script file: "/Users/jan/Desktop/_NSIS/unicode-true.nsi" (UTF8)
    Processed 1 file, writing output (x86-unicode):
    libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
    

    However, using the built-in terminal of Visual Studio Code the script compiles fine. Also any script with Unicode false compiles fine.

    Sublime Text 3 (Build 3210)

    Compiles just fine

    Assumption

    I think this brings us back to Emmet's initial posting, in which he suspects that this is somehow related to NodeJS/Electron. However, others in this thread have stated otherwise.

     

    Last edit: idleberg 2021-07-07
  • idleberg

    idleberg - 2021-07-26

    Following the upgrade to NSIS v3.07 in the Homebrew formula, we have applied a workaround that allows compiling Unicode installers in their test environment (Docker through GitHub Actions). Following Emmet's advice, we checked the values of the locale and set it explicitly to en_GB.UTF-8. As a result, the Unicode installer compiles fine.

    As a follow-up, I tested the following:

    # Manipulate the default locale
    $ export LC_ALL=C  
    $ export LANG=C
    
    # Compile Unicode installer
    $ makensis -X"Outfile /dev/null" -X"Unicode true" -X"Section" -X"SectionEnd"
    
    Processed 4 command line commands, writing output (x86-unicode):
    libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
    fish: 'makensis -X"Outfile /dev/null...' terminated by signal SIGABRT (Abort)
    
    # Reset the default locale
    $ export LC_ALL=en_US.UTF-8  
    $ export LANG=en_US.UTF-8
    
    # Compile Unicode installer
    $ makensis -X"Outfile /dev/null" -X"Unicode true" -X"Section" -X"SectionEnd"
    
    Processed 4 command line commands, writing output (x86-unicode):
    
    Output: "/dev/null"
    Install: 1 page (64 bytes), 1 section (4120 bytes), 1 instruction (28 bytes), 99 strings (536 bytes), 1 language table (194 bytes).
    
    Using zlib compression.
    
    EXE header size:               37888 / 39424 bytes
    Install code:                    457 / 3286 bytes
    Install data:                      0 / 0 bytes
    CRC (0x5549BA54):                  4 / 4 bytes
    
    Total size:                    38349 / 42714 bytes (89.7%)
    

    This seems to confirm Emmet's assumption, that the error only appears when the locale doesn't use a valid language. I'm wondering if makensis should run a basic check and set a fallback value for the locale, if necessary.

     

Log in to post a comment.