microsoft / sql-server-samples

Azure Data SQL Samples - Official Microsoft GitHub Repository containing code samples for SQL Server, Azure SQL, Azure Synapse, and Azure SQL Edge
Other
9.76k stars 8.79k forks source link

sqlcmd: Memory allocation failed (OSX) #576

Open ghost opened 5 years ago

ghost commented 5 years ago

brew install mssql-tools microsoft/mssql-release/mssql-tools 17.3.1.1 is already installed and up-to-date

brew --version Homebrew 2.1.5 Homebrew/homebrew-core (git revision b2f0; last commit 2019-06-13) Homebrew/homebrew-cask (git revision 3fdb1; last commit 2019-06-13)

sqlcmd -S "<server>" -U "<user>" -P "<password>" Q "<query>" // replaced to not reveal company info

sqlcmd(78448,0x10f9b85c0) malloc: can't allocate region mach_vm_map(size=18446744073709535232) failed (error code=3) sqlcmd(78448,0x10f9b85c0) malloc: set a breakpoint in malloc_error_break to debug Sqlcmd: Error: Internal error at PrintODBCDiagRecs (Reason: Memory allocation failed). sqlcmd(78448,0x10f9b85c0) malloc: can't allocate region mach_vm_map(size=18446744073709535232) failed (error code=3) sqlcmd(78448,0x10f9b85c0) malloc: set a breakpoint in malloc_error_break to debug Sqlcmd: Error: Internal error at PrintODBCDiagRecs (Reason: Memory allocation failed). sqlcmd(78448,0x10f9b85c0) malloc: can't allocate region mach_vm_map(size=18446744073709535232) failed (error code=3) sqlcmd(78448,0x10f9b85c0) malloc: set a breakpoint in malloc_error_break to debug Sqlcmd: Error: Internal error at PrintODBCDiagRecs (Reason: Memory allocation failed).

Mojave 10.14.5

steffanhalv commented 5 years ago

I got this problem to, I can connect to the database using a windows machine but not macos.

Ref: https://www.microsoft.com/en-us/sql-server/developer-get-started/node/mac/

Brew:

brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew --version
Homebrew 2.1.6

Install:

brew reinstall msodbcsql17 mssql-tools==> Reinstalling microsoft/mssql-release/msodbcsql17 
==> Downloading https://download.microsoft.com/download/1/9/A/19AF548A-6DD3-4B48-88DC-724E9A
Already downloaded: /Users/steffan/Library/Caches/Homebrew/downloads/0975b953f795671e119cba85c149c618b3eadab8a5844b921b99d43a3207b828--msodbcsql-17.3.1.1.tar.gz
The license terms for this product can be downloaded from
https://aka.ms/odbc17eula and found in
/usr/local/share/doc/msodbcsql17/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES 
==> odbcinst -u -d -n "ODBC Driver 17 for SQL Server"
==> odbcinst -i -d -f ./odbcinst.ini
==> Caveats
If you installed this formula with the registration option (default), you'll
need to manually remove [ODBC Driver 17 for SQL Server] section from
odbcinst.ini after the formula is uninstalled. This can be done by executing
the following command:
    odbcinst -u -d -n "ODBC Driver 17 for SQL Server"
==> Summary
🍺  /usr/local/Cellar/msodbcsql17/17.3.1.1: 9 files, 2.0MB, built in 6 seconds
==> Reinstalling microsoft/mssql-release/mssql-tools 
==> Downloading https://download.microsoft.com/download/F/D/1/FD16AA69-F27D-440E-A15A-6C521A
Already downloaded: /Users/steffan/Library/Caches/Homebrew/downloads/e19cb8347a5184398fea23e2f4e68d4026ea69a843eae9e2b99158c499d4cbfc--mssql-tools-17.3.1.1.tar.gz
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/local/share/doc/mssql-tools/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES
🍺  /usr/local/Cellar/mssql-tools/17.3.1.1: 11 files, 1.2MB, built in 4 seconds
==> Caveats
==> msodbcsql17
If you installed this formula with the registration option (default), you'll
need to manually remove [ODBC Driver 17 for SQL Server] section from
odbcinst.ini after the formula is uninstalled. This can be done by executing
the following command:
    odbcinst -u -d -n "ODBC Driver 17 for SQL Server"

Attempt on connect

sqlcmd -S filserver -U sa -P xxxx
sqlcmd(50794,0x11cb425c0) malloc: can't allocate region
*** mach_vm_map(size=18446744073709543424) failed (error code=3)
sqlcmd(50794,0x11cb425c0) malloc: *** set a breakpoint in malloc_error_break to debug
Sqlcmd: Error: Internal error at PrintODBCDiagRecs (Reason: Memory allocation failed).
sqlcmd(50794,0x11cb425c0) malloc: can't allocate region
*** mach_vm_map(size=18446744073709543424) failed (error code=3)
sqlcmd(50794,0x11cb425c0) malloc: *** set a breakpoint in malloc_error_break to debug
Sqlcmd: Error: Internal error at PrintODBCDiagRecs (Reason: Memory allocation failed).
sqlcmd(50794,0x11cb425c0) malloc: can't allocate region
*** mach_vm_map(size=18446744073709543424) failed (error code=3)
sqlcmd(50794,0x11cb425c0) malloc: *** set a breakpoint in malloc_error_break to debug
Sqlcmd: Error: Internal error at PrintODBCDiagRecs (Reason: Memory allocation failed).

Mojave 10.14.5

sincoew commented 5 years ago

same problem on Mojave 10.14.5

sqlcmd(12675,0x11ac705c0) malloc: can't allocate region
*** mach_vm_map(size=18446744073709527040) failed (error code=3)
sqlcmd(12675,0x11ac705c0) malloc: *** set a breakpoint in malloc_error_break to debug
Sqlcmd: Error: Internal error at PrintODBCDiagRecs (Reason: Memory allocation failed).
charleshimmer commented 4 years ago

Anybody find a fix for this problem?

croblesm commented 4 years ago

I'm having exactly the same problem :(

shaximinion commented 4 years ago

I had this problem when Dynamic Memory was enabled for the VM - Switching this off worked - It was a setting in the Hyper V VM manager - not sure if it is applicable to your scenarios however.

croblesm commented 4 years ago

I think this problem was related to the mssql-tools package at that time (late 2019). I'm no longer having any problem using the latest version(17.5.2.1):

Current status:

[dba mastery] $  brew info microsoft/mssql-release/mssql-tools
microsoft/mssql-release/mssql-tools: stable 17.5.2.1
Sqlcmd and Bcp for Microsoft(R) SQL Server(R)
https://msdn.microsoft.com/en-us/library/ms162773.aspx
/usr/local/Cellar/mssql-tools/17.5.2.1 (11 files, 869KB) *
  Built from source on 2020-03-23 at 21:54:31
From: https://github.com/Microsoft/homebrew-mssql-release/blob/master/Formula/mssql-tools.rb
==> Dependencies
Required: unixodbc ✔, openssl ✔, msodbcsql17 ✔

Checking macOS version:

[dba mastery] $  sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.4
BuildVersion:   19E266

Checking SQLCMD version:

[dba mastery] $  sqlcmd -?
Microsoft (R) SQL Server Command Line Tool
Version 17.5.0002.1 Linux

In case you want to update your mssql-tools package simply run this command: brew upgrade microsoft/mssql-release/mssql-tools

Cheers,