Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on cygwin x64 in nix 2.3.9 #4360

Open
viric opened this issue Dec 14, 2020 · 8 comments
Open

Crash on cygwin x64 in nix 2.3.9 #4360

viric opened this issue Dec 14, 2020 · 8 comments

Comments

@viric
Copy link
Member

viric commented Dec 14, 2020

I try to build something that requires a file in the binary cache. It crashes bad, in a way that the program returns 0 so it's undetected by scripts.
In gdb the backtrace at crash point is useless (with set cygwin-exceptions on).

#0  _sigfe () at sigfe.s:31
#1  0x00000001800d9a10 in lfind () from /usr/bin/cygwin1.dll
Backtrace stopped: Cannot access memory at address 0x0
(gdb) info symbol 0x00000001800d9a10
malloc in section .text of /usr/bin/cygwin1.dll

The crash seems realiably to happen in a lstat() call in the thread lambda https://github.com/NixOS/nix/blob/2.3.9/src/libstore/build.cc#L4093
It's "deletePath()" that calls lstat(). It's the first lstat() outside the the main thread - in case it's a cygwin problem. But I tried to reproduce that in a program apart (call lstat from another thread) and all worked fine.

It could be that the code is simply racy and the race goes bad under cygwin. I checked that the 'this' SubstitutionGoal is not destructed before the crash; that part should be fine. SubstitutionGoal::finished() is not called either.

#0  lstat64 (                                                                                        
    name=0x800e2e9e8 "/nix/store/k44n5wvjwvnpam0yv5zshqiqxjzdz0il-boost_1_66_0.tar.bz2",             
buf=0xff7fbf00)                                                                                      
    at /ext/build/mknetrel/src/cygwin-snapshot-20201207-1/winsup/cygwin/syscalls.cc:2121             
#1  0x00000001801305bb in _sigfe () at sigfe.s:35                                                    
#2  0x00000005eb843112 in nix::_deletePath (path=...,                                                
    bytesFreed=@0xff7fc4f8: 0) at src/libutil/util.cc:394                                            
#3  0x00000005eb843607 in nix::deletePath (path=..., bytesFreed=@0xff7fc4f8: 0)                      
    at src/libutil/util.cc:432                                                                       
#4  0x00000005eb8435d5 in nix::deletePath (path=...) at src/libutil/util.cc:424                      
#5  0x000000051522beab in nix::LocalStore::addToStore (this=0x80008b7e0,                             
    info=..., source=..., repair=nix::NoRepair, checkSigs=nix::CheckSigs,                            
    accessor=...) at src/libstore/local-store.cc:1008                                                
#6  0x00000005152577a7 in nix::copyStorePath (srcStore=..., dstStore=...,                            
    storePath=..., repair=nix::NoRepair, checkSigs=nix::CheckSigs)                                   
    at src/libstore/store-api.cc:645                                                                 
#7  0x00000005151f0e85 in operator() (__closure=0x800e22358)                                         
    at src/libstore/build.cc:4093                                                                    

nix 2.0.4 works fine.

@viric viric added the bug label Dec 14, 2020
@viric
Copy link
Member Author

viric commented Dec 14, 2020

cc @edolstra @svanderburg

@viric viric changed the title Crash on cygwin in nix 2.3.9 Crash on cygwin x64 in nix 2.3.9 Dec 14, 2020
@viric
Copy link
Member Author

viric commented Dec 15, 2020

I traced that to boost coroutine2 not working under cygwin x64.

The crash happens here, afaiu:
https://github.com/NixOS/nix/blob/2.3.9/src/libutil/serialise.cc#L188

I filed a bug to them; they don't claim cygwin support anywhere, though.
boostorg/coroutine2#34

Can there be an alternative code without coroutines, for cygwin builds?

The last nix without coroutines was 2.0.x, as they were introduced in 2.1.

@viric
Copy link
Member Author

viric commented Dec 16, 2020

"unfortunately cygwin is not supported", in the boost github issue.

@viric
Copy link
Member Author

viric commented Dec 16, 2020

I built boost 1.75 and nix 2.3.9 with the flags below, and all worked!
https://www.boost.org/doc/libs/1_75_0/libs/context/doc/html/context/architectures.html

" If the architecture is not supported but the platform provides ucontext_t, Boost.Context should be compiled with BOOST_USE_UCONTEXT and b2 property context-impl=ucontext. "

Unfortunately the cygwin boost 1.66 are built without that b2 property. I'll try to report that.

@stale
Copy link

stale bot commented Jun 14, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Jun 14, 2021
@corngood
Copy link
Contributor

I've been trying to get nix working on cygwin for ages. My progress is in #4953.

I didn't have the same luck as you with ucontext: https://cygwin.com/pipermail/cygwin-developers/2021-December/012536.html

I've actually got through all the changes needed to build nix from nixpkgs on cygwin, but it involved a lot of hacks, like the ones from the PR, a modified version of cygwin, etc.

Did you make any more progress?

@stale stale bot removed the stale label Dec 22, 2021
@viric
Copy link
Member Author

viric commented Dec 22, 2021 via email

@stale
Copy link

stale bot commented Jul 10, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants