You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"stack smashing detected" since recent 23.05 upstream change when entering nix-shell with buildFHSUserEnv #262080
I'm on a flake-based system with NixOS 23.05 on a x86_64 machine.
I have a reproducible bug that came in very lately in NixOS 23.05 stable. When opening a nix-shell in a specific project, the nix-shell itself creates a pkgs.buildFHSUserEnv with many inputs and end's up with the following error:
It's hard to create a minimal example and I can't provide you the original nix-shell as it relies on some company-internal Nix files.
I know that rev 5a237ae (nixos-23.05 branch) from October 7th works and the NixOS 23.05 branch head from October 18th doesn't work. I verified that the issue is not caused by the Linux kernel update from 6.5.5 to 6.5.7. I think it's glibc or another very basic component.
I tried to do some kind of "manual bisecting" by going commit by commit through the log and build my NixOS system based on that nixpkgs version, but this failed as my system tried to build like everything from nixpkgs, i.e., all the derivations aren't cached (anymore).
Steps To Reproduce
I'm sorry that I can't provide a real reproducer now due to the limitations mentioned above.
Expected behavior
A normal nix-shell should open.
Screenshots
Additional context
None.
Notify maintainers
Not sure who is in charge as it is not clear what the problem is.
Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.
Reacted by Julian Stecklina, Carlos, ورد, Sem, Rokas Urbelis, Zachary Kuhn, Zachary Hanham, Daniel Poelzleithner, Daniel Langbein, carschandler and 2 more
The message comes from the stack protector compiled into the binary by gcc, if I'm not mistaken. Maybe this is the root cause as something has changed their?
I am having a similar problem when using vscode-fhs or unstable vscode-fhs. Plugins are crashing and terminal isn't working saying stack smashing detected.
Same here - getting this error when trying to open terminal / github / etc. in intellij-idea (both community and ultimate) via flake.nix that defines fhs
flake.nix file:
{
# Flake.nix with FHSEnv to run idea-community so that github copilot plugin works
# Made for SD class in IST, feel free to improve it
# You can run idea-community by typing "nix run .#fhs_env" in the dev shell
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
];
};
apps.fhs_env = {
type = "app";
program = let drv = pkgs.buildFHSUserEnv {
name = "idea-ultimate";
targetPkgs = pkgs: ( with pkgs; [
jetbrains.idea-ultimate
]);
runScript = "idea-ultimate";
}; in "${drv}/bin/idea-ultimate";
};
}
);
}
Running this as:
cdc <folder with flake.nix>
nix develop
export NIXPKGS_ALLOW_UNFREE=1 && nix run .#fhs_env --impure &> /tmp/idea-run-log &
Not getting the "stack smashing detected" error when running idea without fhs - however this doesn't work for me for another reason, github copilot login is not working, so I am using a variation of this workaround.
Example of stack trace:
2023-10-23 11:21:02,445 [ 6323] WARN - #git4idea.repo.GitUntrackedFilesHolder - *** stack smashing detected ***: terminated
com.intellij.openapi.vcs.VcsException: *** stack smashing detected ***: terminated
at git4idea.commands.GitCommandResult.throwOnError(GitCommandResult.java:156)
at git4idea.commands.GitCommandResult.getOutputOrThrow(GitCommandResult.java:145)
at git4idea.index.GitIndexStatusUtilKt.getFileStatus(GitIndexStatusUtil.kt:84)
at git4idea.repo.GitUntrackedFilesHolder.refreshFiles(GitUntrackedFilesHolder.java:351)
at git4idea.repo.GitUntrackedFilesHolder.update(GitUntrackedFilesHolder.java:249)
at com.intellij.util.ui.update.DisposableUpdate$1.doRun(DisposableUpdate.java:31)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:361)
at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:339)
at com.intellij.util.ui.update.DisposableUpdate.run(DisposableUpdate.java:19)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:350)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:340)
at com.intellij.util.ui.update.MergingUpdateQueue.doExecute(MergingUpdateQueue.java:297)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:280)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:245)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:249)
at com.intellij.util.Alarm$Request.runSafely(Alarm.java:365)
at com.intellij.util.Alarm$Request.run(Alarm.java:354)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:272)
at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:248)
at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:28)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:221)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:227)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:210)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
at java.base/java.lang.Thread.run(Thread.java:833)
I started seeing this today in my buildFHSUserEnv shells also. Just an empty environment is enough to see the "stack smashing detected". Here is a minimal shell.nix to reproduce (I use a version of this shell.nix with extra packages and hacks, to compile buildroot packages):
let
pkgs = import <nixpkgs> { };
in (pkgs.buildFHSUserEnv {
name = "issue-262080-repro";
}).env
I'm not sure what exactly is crashing with the stack smashing error, I assume it's just some program being executed inside the various shell startup scripts for buildFHSUserEnv.
The regression range is 32dcb45..5550a85 on nixos-23.05. I'm bisecting now but it's taking some time to build everything from source on some commits.
I realised I can do git bisect --first-parent to first find the PR merge commit which introduced the problem. That pointed to #260159 which included a glibc update 894988b which is the most likely culprit. I'm just checking it now.
After quite a bit of rebuilding the world, I confirmed that the glibc: 2.37-8 -> 2.37-39 update 894988b is the commit which introduced this problem.
The crash when entering the buildFHSUserEnv shell, shown in my previous comments, comes from dircolors which is executed by /etc/bashrc. But many other programs die in the same way when they're executed in the FHS shell.
Issue #262775 points out that LD_LIBRARY_PATH is being set by buildFHSUserEnv and I found that if I unset LD_LIBRARY_PATH then the crashes go away. But I'm not sure how the glibc update from 2.37-8 to 2.37-39 is related.
@danc86 thanks for the investigation! @blitz and I try to debug the issue further in a session today - let's see if we trace down the root cause and possibly find solution
But depending on the reproducer this either introduces or fixes the issue. My current hypothesis is that the real issue is #262775 and the glibc update just shuffles things around a bit to make it work/fail depending on the circumstance.
Activity
phip1611 commentedon Oct 19, 2023
The message comes from the stack protector compiled into the binary by gcc, if I'm not mistaken. Maybe this is the root cause as something has changed their?
Hermitter commentedon Oct 19, 2023
I'm encountering the same issue when I use
vscode-fhsNateWright commentedon Oct 20, 2023
I am having a similar problem when using vscode-fhs or unstable vscode-fhs. Plugins are crashing and terminal isn't working saying stack smashing detected.
phip1611 commentedon Oct 20, 2023
@NateWright @Hermitter Do you both mean that the bug on your side also just occurs very recently?
NateWright commentedon Oct 20, 2023
@phip1611 Yes as of a few days ago.
Hermitter commentedon Oct 20, 2023
@phip1611 For me it started 2 days ago
dverlan commentedon Oct 23, 2023
Same here - getting this error when trying to open terminal / github / etc. in intellij-idea (both community and ultimate) via flake.nix that defines fhs
flake.nix file:
Running this as:
Not getting the "stack smashing detected" error when running idea without fhs - however this doesn't work for me for another reason, github copilot login is not working, so I am using a variation of this workaround.
Example of stack trace:
danc86 commentedon Oct 23, 2023
I started seeing this today in my
buildFHSUserEnvshells also. Just an empty environment is enough to see the "stack smashing detected". Here is a minimal shell.nix to reproduce (I use a version of this shell.nix with extra packages and hacks, to compile buildroot packages):Previous behaviour (good):
New behaviour (bad):
I'm not sure what exactly is crashing with the stack smashing error, I assume it's just some program being executed inside the various shell startup scripts for
buildFHSUserEnv.The regression range is 32dcb45..5550a85 on nixos-23.05. I'm bisecting now but it's taking some time to build everything from source on some commits.
danc86 commentedon Oct 23, 2023
I realised I can do
git bisect --first-parentto first find the PR merge commit which introduced the problem. That pointed to #260159 which included a glibc update 894988b which is the most likely culprit. I'm just checking it now.danc86 commentedon Oct 24, 2023
After quite a bit of rebuilding the world, I confirmed that the
glibc: 2.37-8 -> 2.37-39update 894988b is the commit which introduced this problem.The crash when entering the
buildFHSUserEnvshell, shown in my previous comments, comes fromdircolorswhich is executed by/etc/bashrc. But many other programs die in the same way when they're executed in the FHS shell.Issue #262775 points out that
LD_LIBRARY_PATHis being set bybuildFHSUserEnvand I found that if Iunset LD_LIBRARY_PATHthen the crashes go away. But I'm not sure how the glibc update from 2.37-8 to 2.37-39 is related.phip1611 commentedon Oct 24, 2023
@danc86 thanks for the investigation! @blitz and I try to debug the issue further in a session today - let's see if we trace down the root cause and possibly find solution
blitz commentedon Oct 24, 2023
I can reproduce the crash. I get the following
LD_LIBRARY_PATH:If I remove
/usr/lib, the crash disappears.The crashdump I get says this:
Atemu commentedon Oct 25, 2023
Could someone do a first-parent bisect to figure out what triggered this?
blitz commentedon Oct 25, 2023
@Atemu See #262080 (comment).
But depending on the reproducer this either introduces or fixes the issue. My current hypothesis is that the real issue is #262775 and the glibc update just shuffles things around a bit to make it work/fail depending on the circumstance.
Atemu commentedon Oct 25, 2023
Ah, missed that, thanks. Yeah, I suspect the latter too.
nixos-discourse commentedon Oct 27, 2023
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/stack-smashing-detected-packaging-woes/32521/13
nixos-discourse commentedon Nov 12, 2023
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/install-nix-on-debian-stack-smashing-detected-terminated/35363/1
Atemu commentedon Nov 12, 2023
The above is not related to buildFHSEnv.
Does anyone still experience this?
danc86 commentedon Nov 12, 2023
I had been doing this as a workaround:
With latest
nixos-23.05branch my workaround isn't needed. Looks like #263378 has fixed this.