Skip to content

Invoke-WebRequest cashes pwsh installed with latest brew and throws malloc error (PowerShell 7.4.2) #21602

Closed
@b3hni4

Description

@b3hni4

Prerequisites

Steps to reproduce

This only happens with POST requests to the same uri (GET request works as intended)

$serviceUsername = 'XXX'
$serviceUserPassword = Read-Host -AsSecureString
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $serviceUsername, $serviceUserPassword
$body = @{foo = "foo"}
$parameters = @{
          Uri         = "https://xxx.net"
          METHOD      = "POST"
          Credential  = $cred
          Body        = $body | ConvertTo-Json 
          ContentType = 'application/json'
      }
$response = Invoke-WebRequest @parameters
---

pwsh(66802,0x70000453e000) malloc: *** error for object 0x600002bdef20: pointer being freed was not allocated
pwsh(66802,0x70000453e000) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6

This does not happen in version 7.3.12

Expected behavior

Web request returns as expected.

Actual behavior

Shell crashes.

Error details

Get-Error cannot be called as the shell crashes with the following error

pwsh(66802,0x70000453e000) malloc: *** error for object 0x600002bdef20: pointer being freed was not allocated
pwsh(66802,0x70000453e000) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6


### Environment data

```powershell
Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Darwin 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:11:05 PDT 2024; root:xnu-10063.101.17~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being accept

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions