Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.5k
    • Issues 5.5k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 631
    • Merge requests 631
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18261

Using withArgs concurrently segfaults

Summary

Calling withArgs simultaneously from multiple threads crashes the program.

Steps to reproduce

Compile the following program with -threaded and run it with +RTS -N.

import Control.Concurrent ( forkIO )
import Control.Monad ( replicateM_ )
import System.Environment ( withArgs )

main = replicateM_ 64 . forkIO . withArgs [] $ pure ()

I can reproduce this bug by spawning fewer than 64 threads, so that number doesn't seem to matter too much. Similarly I can reproduce the bug when running with -Nx for all x > 1. But as those numbers go down, the likelihood of reproducing this bug seems to go down as well.

At any rate, I see output like this:

double free or corruption (fasttop)
free(): double free detected in tcache 2
Aborted (core dumped)
Segmentation fault (core dumped)
double free or corruption (out)
Aborted (core dumped)
free(): double free detected in tcache 2
Segmentation fault (core dumped)

Expected behavior

I don't really know what multiple calls to withArgs from separate threads should do, but it probably shouldn't segfault 😆

Environment

  • GHC version used: 8.10.1, 8.8.3, 8.6.5

Optional:

  • Operating System: Ubuntu 20.04
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking