1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00
Commit graph

61 commits

Author SHA1 Message Date
Robert Hensing 18485d2d53
Merge pull request #11188 from lf-/jade/kill-int-overflow
Ban integer overflow in the Nix language
2024-08-11 04:24:16 +02:00
Jörg Thalheim 739418504c allow to c api with older c versions
In the FFI world we have many tools that are not gcc/clang and therefore
not always support the latest C standard. This fixes support with cffi
i.e. used in https://github.com/tweag/python-nix
2024-08-02 17:19:45 +02:00
Jade Lovelace 7b6622d733 language: cleanly ban integer overflows
This also bans various sneaking of negative numbers from the language
into unsuspecting builtins as was exposed while auditing the
consequences of changing the Nix language integer type to a newtype.

It's unlikely that this change comprehensively ensures correctness when
passing integers out of the Nix language and we should probably add a
checked-narrowing function or something similar, but that's out of scope
for the immediate change.

During the development of this I found a few fun facts about the
language:
- You could overflow integers by converting from unsigned JSON values.
- You could overflow unsigned integers by converting negative numbers
  into them when going into Nix config, into fetchTree, and into flake
  inputs.

  The flake inputs and Nix config cannot actually be tested properly
  since they both ban thunks, however, we put in checks anyway because
  it's possible these could somehow be used to do such shenanigans some
  other way.

Note that Lix has banned Nix language integer overflows since the very
first public beta, but threw a SIGILL about them because we run with
-fsanitize=signed-overflow -fsanitize-undefined-trap-on-error in
production builds. Since the Nix language uses signed integers, overflow
was simply undefined behaviour, and since we defined that to trap, it
did.

Trapping on it was a bad UX, but we didn't even entirely notice
that we had done this at all until it was reported as a bug a couple of
months later (which is, to be fair, that flag working as intended), and
it's got enough production time that, aside from code that is IMHO buggy
(and which is, in any case, not in nixpkgs) such as
https://git.lix.systems/lix-project/lix/issues/445, we don't think
anyone doing anything reasonable actually depends on wrapping overflow.

Even for weird use cases such as doing funny bit crimes, it doesn't make
sense IMO to have wrapping behaviour, since two's complement arithmetic
overflow behaviour is so *aggressively* not what you want for *any* kind
of mathematics/algorithms. The Nix language exists for package
management, a domain where bit crimes are already only dubiously in
scope to begin with, and it makes a lot more sense for that domain for
the integers to never lose precision, either by throwing errors if they
would, or by being arbitrary-precision.

Fixes: https://github.com/NixOS/nix/issues/10968
Original-CL: https://gerrit.lix.systems/c/lix/+/1596

Change-Id: I51f253840c4af2ea5422b8a420aa5fafbf8fae75
2024-07-30 18:13:05 -07:00
John Ericson 3b49f7a143
Deduplicate our many package.nix a bit (#11175)
- They should all be built in parallel

- They should all use strict deps by default
2024-07-25 03:12:39 +00:00
John Ericson d3cee8160c Add missing threads deps 2024-07-22 11:46:54 -04:00
poweredbypie 0ec5e3a1bc
Progress on Wine CI support, MinGW dev shell with Meson (#10975)
* Only build perl subproject on Linux

* Fix various Windows regressions

* Don't put the emulator hook in test builds

  We run the tests in a separate derivation. Only need it for the dev shell.

* Fix native dev shells

* Fix cross dev shells we don't know how to emulate

Co-authored-by: PoweredByPie <poweredbypie@users.noreply.github.com>
Co-authored-by: Joachim Schiele <js@lastlog.de>
Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
2024-07-21 22:03:04 +00:00
John Ericson bc83b9dc1f Remove comparator.hh and switch to <=> in a bunch of places
Known behavior changes:

- `MemorySourceAccessor`'s comparison operators no longer forget to
  compare the `SourceAccessor` base class.

Progress on #10832

What remains for that issue is hopefully much easier!
2024-07-12 14:54:18 -04:00
John Ericson 337a5a23b7
Merge pull request #11089 from NixOS/warnings-includes
Fix warnings and optimize includes
2024-07-12 10:29:26 -04:00
Robert Hensing 8df041cbc6 Solve unused header warnings reported by clangd 2024-07-12 15:37:54 +02:00
John Ericson 3fc77f281e No global settings in libnixfetchers and libnixflake
Progress on #5638

There are still a global fetcher and eval settings, but they are pushed
down into `libnixcmd`, which is a lot less bad a place for this sort of
thing.

Continuing process pioneered in
52bfccf8d8.
2024-07-12 08:50:28 -04:00
Eelco Dolstra 61080554ab SymbolStr: Remove std::string conversion
This refactoring allows the symbol table to be stored as something
other than std::strings.
2024-07-11 17:43:10 +02:00
Robert Hensing 0729f0a113 packaging: Pass version directly 2024-07-06 17:52:57 +02:00
John Ericson e4056b9afd
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-07-04 17:48:27 -04:00
John Ericson 4d6bc61b8d Fix things 2024-07-02 09:26:22 -04:00
John Ericson 513f6b9718 meson: Prelink links to avoid missing C++ initializers
This is the same as what the old build system did in
7eca8a16ea, done for the same reasons.
2024-07-02 09:26:22 -04:00
John Ericson 912c517bc0 Fix build of unit tests 2024-07-02 09:26:22 -04:00
John Ericson 479befa76d More fixes 2024-07-02 09:26:22 -04:00
John Ericson 6a0582d9fd Rename file to avoid reserved name 2024-07-02 09:26:22 -04:00
John Ericson 46ec69a483 Everything builds in the dev shell now 2024-07-02 09:26:22 -04:00
John Ericson 429d6ae2b5 Add missing package.nix 2024-07-02 09:26:22 -04:00
John Ericson 8399bd6b8f Dedup 2024-07-02 09:26:21 -04:00
John Ericson d6f57f3260 More dedup 2024-07-02 09:23:25 -04:00
John Ericson c88f83b471 More dedup 2024-07-02 09:23:25 -04:00
John Ericson d902481a36 Better org 2024-07-02 09:23:25 -04:00
John Ericson a81e319528 Deduplicating 2024-07-02 09:23:24 -04:00
John Ericson 4fa8068b78 Mesonify other external API 2024-07-02 09:23:24 -04:00
John Ericson 52bfccf8d8 No global eval settings in libnixexpr
Progress on #5638

There is still a global eval settings, but it pushed down into
`libnixcmd`, which is a lot less bad a place for this sort of thing.
2024-06-24 12:15:16 -04:00
Robert Hensing b94e1d6218 C API: Value -> nix_value
See issue https://github.com/NixOS/nix/issues/10434
2024-06-13 18:51:58 +02:00
Robert Hensing 5d8118d9cb C API: Docs 2024-06-13 18:23:21 +02:00
Robert Hensing c50db4e58c C API: Add nix_value_{inc,dec}ref
- Can be implemented more easily by more eval architectures.
- Better types in generated bindings remove some uncertainty and doubt.
2024-06-13 18:21:04 +02:00
Robert Hensing 0b56c98b1c C API: Value -> nix_value 2024-06-13 18:18:36 +02:00
John Ericson 1a32490aca
Merge pull request #10835 from hercules-ci/update-nixpkgs-24.05
Update to Nixpkgs 24.05
2024-06-05 17:56:16 -04:00
Philipp 214051ba79
clarify not on nix_value_force (#10842)
* clarify not on `nix_value_force`

Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2024-06-04 07:41:04 +00:00
Robert Hensing 27f880c098 Format after clang-format update 2024-06-03 18:38:56 +02:00
Philipp Zander 25e2b1f7f7 improve note in nix_value_force documentation 2024-06-03 09:55:44 +02:00
Philipp 2bd66922ee
add empty line to documentation comments after @brief field (#10800)
* add empty line to documentation comments after `@brief` field

Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
2024-05-28 23:05:40 +00:00
Robert Hensing 2497d10351 C API: Add nix_value_call_multi, NIX_VALUE_CALL
_multi can be implemented more efficiently.
NIX_VALUE_CALL is a convenient way to invoke it.
2024-05-23 21:24:06 +02:00
Robert Hensing 4bc4fb40ea C API: builtin -> custom function
Not all primops will be in `builtins`.
2024-05-23 21:23:14 +02:00
Robert Hensing 8ef6efc184 C API: Require non-thunk value from primop definition 2024-05-23 21:22:59 +02:00
Robert Hensing 8884227045 C API: Require initialized value from primop definition 2024-05-23 21:22:21 +02:00
Robert Hensing a942a34469 C API: Fix nix_c_primop_wrapper for strict initializers
https://github.com/NixOS/nix/pull/10555 added a check requiring
that output parameters always have an uninitialized Value as argument.

Unfortunately the output parameter of the primop callback received
a thunk instead.

See the comment for implementation considerations.
2024-05-23 18:32:49 +02:00
Robert Hensing bd7a074636
Merge pull request #10724 from prednaz/libexpr-c_example
remove redundant and outdated example from `libexpr-c` documentation
2024-05-22 12:59:14 +02:00
Philipp Zander 142222030c remove redundant and outdated example from libexpr-c documentation 2024-05-21 14:00:34 +02:00
Philipp e0bfa6c55f
small additions to the documentation of nix_store_open and nix_state_create (#10728) 2024-05-20 08:27:33 +02:00
Philipp Zander f63292462c document nix_external_print's printer parameter to be an out parameter 2024-05-16 02:55:38 +02:00
Philipp Zander 359043ed0d add missing c api parameter names to documentation 2024-05-16 02:55:38 +02:00
José Luis Lafuente 6acf02b32a
C API: source argument to nix_copy_value should be const 2024-04-21 22:46:18 +02:00
José Luis Lafuente 8d70db3251
C API: add check_value_[in,out] helper functions 2024-04-21 22:44:14 +02:00
José Luis Lafuente ccad6e94e2
C API: add (un)initialized value checks 2024-04-21 22:44:14 +02:00
Roland Coeurjoly 40a6a9fdb8 Rename SearchPath to LookupPath and searchPath to lookupPath 2024-04-13 17:35:15 +02:00