!lTqhfnNvIkcEackxxk:matrix.org

Nix Bindings

90 Members
Nix C API https://github.com/NixOS/nix/blob/master/doc/manual/src/c-api.md, language-specific bindings, and their use cases (currently broken link: https://nixos.org/manual/nix/unstable/c-api)23 Servers

Load older messages


SenderMessageTime
7 Apr 2025
@o-santi:matrix.orgLeonardo Santiago Okay, it finally clicked to me that the reason that I had no line number and source information was because I was compiling nix-expr without source information. When I managed to build it with debug information, it stopped segfaulting :D 16:22:22
@o-santi:matrix.orgLeonardo Santiago

This is what I did, and if I change nix-expr-c for nix.libs.nix-expr-c it goes back to segfaulting

mkDebug = p: p.overrideAttrs (old: old // {                                                                                                           
          dontStrip = true;                                                                                                                                   
          mesonBuildType = "debugoptimized";                                                                                                                  
          NIX_CFLAGS_COMPILE = toString (old.NIX_CFLAGS_COMPILE or "") + " -ggdb -Og";                                                                        
});                                                                                                                                                   
nix-expr-c = (mkDebug nix.libs.nix-expr-c).override { nix-expr = mkDebug nix.libs.nix-expr; };
nix-deps = map mkDebug [ nix.libs.nix-store-c nix-expr-c nix.libs.nix-util-c ]; 
16:23:56
@o-santi:matrix.orgLeonardo Santiago *

This is what I did, and if I change nix-expr-c for nix.libs.nix-expr-c it goes back to segfaulting

inputs = { 
  nix.url` = "github:nixos/nix/2.27.0;
};
outputs = { ... } : { 
...
nix = inputs.nix.packages.${system}.nix;
mkDebug = p: p.overrideAttrs (old: old // {                                                                                                           
          dontStrip = true;                                                                                                                                   
          mesonBuildType = "debugoptimized";                                                                                                                  
          NIX_CFLAGS_COMPILE = toString (old.NIX_CFLAGS_COMPILE or "") + " -ggdb -Og";                                                                        
});                                                                                                                                                   
nix-expr-c = (mkDebug nix.libs.nix-expr-c).override { nix-expr = mkDebug nix.libs.nix-expr; };
nix-deps = map mkDebug [ nix.libs.nix-store-c nix-expr-c nix.libs.nix-util-c ]; 
16:24:48
@o-santi:matrix.orgLeonardo Santiago *

This is what I did, and if I change nix-expr-c for nix.libs.nix-expr-c it goes back to segfaulting

inputs = { 
  nix.url` = "github:nixos/nix/2.27.0";
};
outputs = { ... } : { 
...
nix = inputs.nix.packages.${system}.nix;
mkDebug = p: p.overrideAttrs (old: old // {                                                                                                           
          dontStrip = true;                                                                                                                                   
          mesonBuildType = "debugoptimized";                                                                                                                  
          NIX_CFLAGS_COMPILE = toString (old.NIX_CFLAGS_COMPILE or "") + " -ggdb -Og";                                                                        
});                                                                                                                                                   
nix-expr-c = (mkDebug nix.libs.nix-expr-c).override { nix-expr = mkDebug nix.libs.nix-expr; };
nix-deps = map mkDebug [ nix.libs.nix-store-c nix-expr-c nix.libs.nix-util-c ]; 
16:24:52
@o-santi:matrix.orgLeonardo Santiago *

This is what I did, and if I change nix-expr-c for nix.libs.nix-expr-c it goes back to segfaulting

inputs = { 
  nix.url = "github:nixos/nix/2.27.0";
};
outputs = { ... } : { 
...
nix = inputs.nix.packages.${system}.nix;
mkDebug = p: p.overrideAttrs (old: old // {                                                                                                           
          dontStrip = true;                                                                                                                                   
          mesonBuildType = "debugoptimized";                                                                                                                  
          NIX_CFLAGS_COMPILE = toString (old.NIX_CFLAGS_COMPILE or "") + " -ggdb -Og";                                                                        
});                                                                                                                                                   
nix-expr-c = (mkDebug nix.libs.nix-expr-c).override { nix-expr = mkDebug nix.libs.nix-expr; };
nix-deps = map mkDebug [ nix.libs.nix-store-c nix-expr-c nix.libs.nix-util-c ]; 
16:24:58
@o-santi:matrix.orgLeonardo Santiago Robert Hensing (roberth): Is this UB? 16:27:29
@o-santi:matrix.orgLeonardo Santiago * Robert Hensing (roberth): Could this be UB? 16:41:45
@o-santi:matrix.orgLeonardo Santiago

Removing mesonBuildType and NIX_CFLAGS_COMPILE and keeping only dontStrip finally made it segfault with debug symbols:

#0  0x00007ffff68ac8d7 in nix::EvalState::callFunction (this=0x5b7b00, fun=..., args=..., vRes=..., pos=...) at <artificial>:1507                           
#1  0x00007ffff68b034c in nix::ExprCall::eval (this=0x648580, state=..., env=..., v=...) at ../stl_iterator.h:90                                            
#2  0x00007ffff68af62b in nix::EvalState::forceValue (pos=..., v=..., this=0x5b7b00) at /build/source/src/libexpr/build/value.hh:96                         
#3  nix::ExprSelect::eval (this=0x648540, state=..., env=..., v=...) at <artificial>:1443                                                                   
#4  0x00007ffff68af158 in nix::EvalState::forceValue (pos=..., v=..., this=0x5b7b00) at /build/source/src/libexpr/build/value.hh:96                         
#5  nix::ExprVar::eval (this=<optimized out>, state=..., env=..., v=...) at <artificial>:1372                                                               
#6  0x00007ffff68af3d9 in nix::ExprSelect::eval (this=0x17f49f0, state=..., env=..., v=...) at <artificial>:1402                                            
#7  0x00007ffff68b0ed1 in nix::ExprOpConcatLists::eval (this=0x17f4a30, state=..., env=..., v=...) at <artificial>:1948                                     
#8  0x00007ffff6905617 in nix::EvalState::forceValue (pos=..., v=..., this=<optimized out>, this=<optimized out>, v=..., pos=...)                           
    at /nix/store/9c9h0zbqa9xfk6pk4387l1h9pj28r692-nix-util-2.27.0-dev/include/nix/aligned_buffer.h:96                                                      
#9  nix::EvalState::forceList (errorCtx=..., pos=..., v=..., this=<optimized out>, this=<optimized out>, v=..., pos=..., errorCtx=...)                      
    at /nix/store/9c9h0zbqa9xfk6pk4387l1h9pj28r692-nix-util-2.27.0-dev/include/nix/aligned_buffer.h:136                                                     
#10 nix::prim_foldlStrict (state=..., pos=..., args=0x7fffff670c00, v=...) at /build/source/src/libexpr/build/new_allocator.h:3485                          
16:48:55
@roberthensing:matrix.orgRobert Hensing (roberth) I've never seen something like <artificial>:1507 before 20:23:52
@roberthensing:matrix.orgRobert Hensing (roberth) maybe it's just eval.cc? 20:25:14
@roberthensing:matrix.orgRobert Hensing (roberth) can't glean much from this, but maybe this happens due to a missing garbage collection root (erroneous decref / missing incref?) or any other kind of corruption 20:26:35
@roberthensing:matrix.orgRobert Hensing (roberth)a change to code layout may well have knock-on effects that cause a corruption to happen (all else equal). That's regardless of whether your overrides produce a valid binary, which I do not know.20:28:39

There are no newer messages yet.


Back to Room ListRoom Version: 10