Giter VIP home page Giter VIP logo

ccan's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ccan's Issues

base64 build errors on big endian BSD

When building on powerpc64 FreeBSD 13.2-RELEASE.

cc ccan/ccan/base64/base64.c
ccan/ccan/base64/base64.c:34:10: error: result of comparison of constant 255 with expression of type 'int8_t' (aka 'signed char') is always false [-Werror,-Wt
autological-constant-out-of-range-compare]
        if (ret == (char)0xff) {
            ~~~ ^  ~~~~~~~~~~
ccan/ccan/base64/base64.c:44:57: error: result of comparison of constant 255 with expression of type 'const signed char' is always true [-Werror,-Wtautologica
l-constant-out-of-range-compare]
        return (maps->decode_map[(const unsigned char)b64char] != (char)0xff);
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~
2 errors generated.
gmake: *** [Makefile:890: ccan-base64.o] Error 1

Looks like I'm hitting the same error on powerpc64 OpenBSD 7.2

CC: cc -DBINTOPKGLIBEXECDIR="../libexec/c-lightning" -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector-strong -Og -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/libbacktrace/ -I external/gheap/ -I external/powerpc64-unknown-openbsd7.2/libbacktrace-build -I external/libsodium/src/libsodium/include -I external/libsodium/src/libsodium/include/sodium -I external/powerpc64-unknown-openbsd7.2/libsodium-build/src/libsodium/include -I . -I/usr/local/include -I/usr/local/include     -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS  -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -DCOMPAT_V0100=1 -DCOMPAT_V0121=1 -DBUILD_ELEMENTS=1  -c -o
LD: cc   -Og  config.vars  -Lexternal/powerpc64-unknown-openbsd7.2 -lwallycore -lsecp256k1 -ljsmn -lbacktrace -lsodium -L/usr/local/include -lm -lgmp -L/usr/local/lib -lsqlite3 -lz  -o
cc ccan/ccan/base64/base64.c
ccan/ccan/base64/base64.c:34:10: error: result of comparison of constant 255 with expression of type 'int8_t' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
        if (ret == (char)0xff) {
            ~~~ ^  ~~~~~~~~~~
ccan/ccan/base64/base64.c:44:57: error: result of comparison of constant 255 with expression of type 'const signed char' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
        return (maps->decode_map[(const unsigned char)b64char] != (char)0xff);
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~
2 errors generated.
gmake: *** [Makefile:867: ccan-base64.o] Error 1

Non-conforming Isaac64 PRNG

I know this is an older project, but people are probably always looking for a fast PRNG.

Your implementation does not seem to output numbers that jive with those generated from the original C implementation by Bob Jenkins: https://[burtleburtle.net/bob/c/isaac64.c](https://burtleburtle.net/bob/c/isaac64.c

It also does not match the expected output published by the Rust project here: https://docs.rs/rand_isaac/latest/src/rand_isaac/isaac64.rs.html#84

Nor does it match the expected output published by Zig here: https://github.com/ziglang/zig/blob/master/lib/std/rand/Isaac64.zig

I'm an Isaac fan, and your work is great.

The code in your repo outputs the following as the first 16 random 64-bit integers on an unseeded run:

Rng #0 == 0x9d39247e33776d41
Rng #1 == 0x2af7398005aaa5c7
Rng #2 == 0x44db015024623547
Rng #3 == 0x9c15f73e62a76ae2
Rng #4 == 0x75834465489c0c89
Rng #5 == 0x3290ac3a203001bf
Rng #6 == 0x0fbbad1f61042279
Rng #7 == 0xe83a908ff2fb60ca
Rng #8 == 0x0d7e765d58755c10
Rng #9 == 0x1a083822ceafe02d
Rng #10 == 0x9605d5f0e25ec3b0
Rng #11 == 0xd021ff5cd13a2ed5
Rng #12 == 0x40bdf15d4a672e32
Rng #13 == 0x011355146fd56395
Rng #14 == 0x5db4832046f3d9e5
Rng #15 == 0x239f8b2d7ff719cc

The following is the expected output:

Rng #0: 0xf67dfba498e4937c
Rng #1: 0x84a5066a9204f380
Rng #2: 0xfee34bd5f5514dbb
Rng #3: 0x4d1664739b8f80d6
Rng #4: 0x8607459ab52a14aa
Rng #5: 0xe78bc5a98529e49
Rng #6: 0xfe5332822ad13777
Rng #7: 0x556c27525e33d01a
Rng #8: 0x8643ca615f3149f
Rng #9: 0xd0771faf3cb04714
Rng #10: 0x30e86f68a37b008d
Rng #11: 0x3074ebc0488a3adf
Rng #12: 0x270645ea7a2790bc
Rng #13: 0x5601a0a8d3763c6a
Rng #14: 0x2f83071f53f325dd
Rng #15: 0xb9090f3d42d2d2ea

Build assertion against conditions which cannot be evaluated.

According to the documentation:

Your compile will fail if the condition isn't true, or can't be evaluated by the compiler.

I find no tests for the latter case, so write one myself:

    int val = 0;
    BUILD_ASSERT(val != 0);
    BUILD_ASSERT(val == 0);

It compiles without any complaining.

ccan: make check log from armv7l

Here I am submitting a make check log for a 32-bit ARM box with i.MX6 based SolidRun's SoC but the same is valid also for Qualcomm MSM8974PRO-AC (see lightning issue link below):

$ uname -a
Linux mail 4.9.150-imx6-sr #1 SMP Sun Jun 9 06:05:39 UTC 2019 armv7l GNU/Linux
$ cat /proc/cpuinfo
processor	: 0
model name	: ARMv7 Processor rev 10 (v7l)
BogoMIPS	: 3.00
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpd32 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x2
CPU part	: 0xc09
CPU revision	: 10

Hardware	: Freescale i.MX6 Quad/DualLite (Device Tree)
Revision	: 61013
Serial		: 0000000000000000

ccan-cdd0b8b5-make_check.log

Should all the tests pass? Is this a big problem?

The same output I also get for Qualcomm MSM8974PRO-AC (Xiaomi Cancro smartphone). I would like to reproduce the issue from ElementsProject/lightning#2818

autodata and static library ?

Hello, I will try to explain my problem here:

I have a library which use autodata.

hkl-factory-private.h:

struct _HklFactory
{
const char *name;
const char *description;
const darray_string axes;
HklFactoryGeometryFunction create_new_geometry;
HklFactoryEngineListFunction create_new_engine_list;
};

define REGISTER_DIFFRACTOMETER(name_, real_name_, description_) \

static HklFactory name_ = {                 \
    .name = real_name_,                 \
    .description = description_,                \
    .axes = DARRAY(hkl_geometry_ ## name_ ## _axes),    \
    .create_new_geometry = &hkl_geometry_new_ ## name_, \
    .create_new_engine_list = &hkl_engine_list_new_ ## name_ \
};                              \
AUTODATA(factories, &name_)

AUTODATA_TYPE(factories, HklFactory);

hkl-factory.c

HklFactory **hkl_factory_get_all(size_t *n)
{
return autodata_get(factories, n);
}

HklFactory _hkl_factory_get_by_name(const char *name, GError *_error)
{
size_t i, n;
HklFactory **factories;

factories = autodata_get(factories, &n);
for(i=0;i<n; ++i)
    if (!strcmp(name, factories[i]->name))
        return factories[i];

return NULL;

}

and then I declare all my registered structure in a bunch of other .c files
REGISTER_DIFFRACTOMETER(twoC, "TwoC", HKL_GEOMETRY_TWOC_DESCRIPTION);
...

When I compile this code as a shared library, there is no problem, I have the expected section filled with all the factories

com-sixs@sixs7:~/picca/hkl.ssh/hkl/.libs$ nm -o libhkl.so | grep xauto
libhkl.so:00000000002467e0 D __start_xautodata_factories
libhkl.so:0000000000246850 D __stop_xautodata_factories

but when I try to generate a static library, I got htis error message

./.libs/libhkl.a(libhkl_la-hkl-factory.o): In function hkl_factory_get_all': /home/experiences/sixs/com-sixs/picca/hkl.ssh/hkl/hkl-factory.c:29: undefined reference to__stop_xautodata_factories'
/home/experiences/sixs/com-sixs/picca/hkl.ssh/hkl/hkl-factory.c:29: undefined reference to __start_xautodata_factories' ./.libs/libhkl.a(libhkl_la-hkl-factory.o): In functionhkl_factory_get_by_name':
/home/experiences/sixs/com-sixs/picca/hkl.ssh/hkl/hkl-factory.c:37: undefined reference to __stop_xautodata_factories' /home/experiences/sixs/com-sixs/picca/hkl.ssh/hkl/hkl-factory.c:37: undefined reference to__start_xautodata_factories'

and indeed:

com-sixs@sixs7:~/picca/hkl.ssh/hkl/.libs$ nm -o libhkl.a | grep xauto
libhkl.a:libhkl_la-hkl-factory.o: U __start_xautodata_factories
libhkl.a:libhkl_la-hkl-factory.o: U __stop_xautodata_factories
libhkl.a:libhkl_la-hkl-binding.o: U __start_xautodata_factories
libhkl.a:libhkl_la-hkl-binding.o: U __stop_xautodata_factories

So my question is, how can I fix this ?

thanks

Frederic

Makefile build fail again!

duplicate symbol __asort in:
ccan/asort/asort.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [tools/ccanlint/ccanlint] Error 1

What does the licence name 'BSD-MIT' name?

I would describe this licence https://github.com/rustyrussell/ccan/blob/9d2d2c49f053018724bcc6e37029da10b7c3d60d/licenses/BSD-MIT as simply the conventional MIT licence and doesn't include any text from the BSD licence.

The OSI doesn't list a 'BSD-MIT' licence (but I know they aren't any kind of authority on licences.)

https://opensource.org/licenses/alphabetical

Could you comment on what you mean when you describe it as the BSD-MIT licence? Is that just another name for MIT or is it meant to say something specific?

problem with generator on 64 bit compters

Hello, I am using generator and coroutine on an i386 computer in order to build my hkl project.
It works fine.

The problem arise when I switch to 64 bits computer and can be reproduce using the current debian unstable source package from here

https://packages.debian.org/source/unstable/hkl

(the problematic version is this one https://tracker.debian.org/news/930678)

It generates this kind of failure via a Segfault.

https://buildd.debian.org/status/fetch.php?pkg=hkl&arch=amd64&ver=5.0.0.2447-1&stamp=1518020479&raw=0

I tryed to debug the problem via gdb and I got this

Program received signal SIGSEGV, Segmentation fault.
generator_new_ (fn=fn@entry=0xaaaaaaae65b8 <trajectory_gen_generator__>, retsize=48, retsize@entry=40) at generator/generator.c:38
38      generator/generator.c: No such file or directory.
(gdb) bt
#0  0x0000aaaaaaae50d8 in generator_new_ (fn=fn@entry=0xaaaaaaae65b8 <trajectory_gen_generator__>, retsize=48, retsize@entry=40) at generator/generator.c:38
#1  0x0000aaaaaaae6b78 in trajectory_gen (tconfig=...) at hkl2.c:246
#2  0x0000aaaaaaae6c2c in Trajectory_solve (tconfig=..., gconfig=..., sconfig=..., move=43690) at hkl2.c:288
#3  0x0000aaaaaaabf324 in main () at sirius.c:161

If we look at the generator line,we get this

gen->base = base;

I do not understand why it work great on 32 bits computer and not on 64 bits computer.

can you help me find the problem. I am ready to test this until it works on 64 bits computer also :))

Cheers

Frederic

HAVE_UCONTEXT check on musl libc

The HAVE_UCONTEXT check returns false on musl-based system (Alpine Linux for example), but is not true because there is the /usr/include/ucontext.h file and after manually changing config.h file the compilation works pretty well until another error - reported separately and I will link it here.

JSON library doesn't work with locales that use comma as decimal separator

ccan/json library uses locale-dependent C routines (strtod() and sprintf()) to deal with numbers. If the program uses a locale with a comma as a decimal separator, the library will truncate numbers on reading (strtod() will ignore . and everything after it) and create broken JSONs (numbers will have , as separator instead of . as required by the standard).

Requesting versioned snapshots

Hello!

I'd like to make a FreeBSD port of ccan -- because I need it for some other software. The ports work best, when the "upstream" releases have versions in the filenames.

Could I trouble you to place ccan-1.0.tar.bz2 (or .xz) next to the ccan.tar.bz2 you already publish? The version-less name can continue pointing -- as a symlink or, better yet, an HTTP-redirect -- at the latest, whatever it is, but people seeking a specific release (for which there is a known checksum, etc.) will continue to be able to download it explicitly.

Thank you in advance!

Spam URL on http://ccodearchive.net/

$ curl http://ccodearchive.net/ | grep visit
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2931    0  2931    0     0  21450      0 --:--:-- --:--:-- --:--:-- 21551
<p>We also have a wiki; feel free to enhance it.<br /><br />To see how graphic codes improve the performance of new <strong><a href="https://www.REDACTEDTONOTPROMOTESPAMMERS.com" target="_blank" title="REDACTEDTONOTPROMOTESPAMMERS">REDACTEDTONOTPROMOTESPAMMERS</a></strong>, REDACTEDTONOTPROMOTESPAMMERS.com<br /></p>

bitmap doesn't work on 32bit x86/ARM

bitmap_zero_range/bitmap_fill_range/bitmap_ffs doesn't work on 32bit platform, since long long is 64 bit while long is 32 bit. The build-in tests simply failed.

@dgibson @rustyrussell The fix is straight forward:

change from

	bitmap_word headmask = -1ULL >> (n % BITMAP_WORD_BITS);
	bitmap_word tailmask = ~(-1ULL >> (m % BITMAP_WORD_BITS));

to

	bitmap_word headmask = -1UL >> (n % BITMAP_WORD_BITS);
	bitmap_word tailmask = ~(-1UL >> (m % BITMAP_WORD_BITS));

generator.h: Generators require coroutines

$ uname -a
Linux singer 5.10.61-0-lts #1-Alpine SMP Thu, 26 Aug 2021 17:42:24 +0000 x86_64 GNU/Linux
$ git clone git://git.ozlabs.org/~ccan/ccan
$ cd ccan
$ git rev-parse --short HEAD
fc29adfb
$ make
...
cc -g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wundef -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -DCCAN_STR_DEBUG=1 -I.  -MMD -MP -MFccan/generator/generator.o.d -MTccan/generator/generator.o -c ccan/generator/generator.c -o ccan/generator/generator.o
In file included from ccan/generator/generator.c:8:
./ccan/generator/generator.h:23:2: error: #error Generators require coroutines
   23 | #error Generators require coroutines
      |  ^~~~~
make: *** [Makefile:32: ccan/generator/generator.o] Error 1

gcc13 error: '_170' may be used uninitialized

There is build error on gcc 13.1.1:

make[2]: Entering directory '/usr/src/RPM/BUILD/sbsigntools-0.9.5/src'
x86_64-alt-linux-gcc -Wall -Wextra --std=gnu99  -I../lib/ccan/ -Werror -pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto    -o sbkeysync sbkeysync-sbkeysync.o sbkeysync-idc.o sbkeysync-image.o sbkeysync-fileio.o  ../lib/ccan/libccan.a -lcrypto -luuid 
In function '_talloc_set_name_const',
    inlined from '_talloc_named_const' at ../lib/ccan/ccan/talloc/talloc.c:352:2,
    inlined from '_talloc_zero' at ../lib/ccan/ccan/talloc/talloc.c:1270:6,
    inlined from 'main' at sbkeysync.c:895:8:
../lib/ccan/ccan/talloc/talloc.c:336:35: error: '_170' may be used uninitialized [-Werror=maybe-uninitialized]
  336 |         struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
      |                                   ^
../lib/ccan/ccan/talloc/talloc.c: In function 'main':
../lib/ccan/ccan/talloc/talloc.c:115:36: note: by argument 1 of type 'const void *' to 'talloc_chunk_from_ptr' declared here
  115 | static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr)
      |                                    ^
lto1: all warnings being treated as errors

#define 'HAVE_UNALIGNED_ACCESS' and [-Wcast-align] warnings on 32bit armv7l

Now I'm chasing kind of the [-Wcast-align] warnings which happens when I build c-Lightning on 32bit armv7l machine.

ccan/ccan/crypto/sha256/sha256.c:213:22: warning: cast increases required alignment of target type [-Wcast-align]
    Transform(ctx->s, (const uint32_t *)data, blocks);
                      ^

Brief system info is:

$ uname -a  # (all)
Linux odroid 4.14.111-158 #1 SMP PREEMPT Tue Apr 16 12:26:31 -03 2019 armv7l armv7l armv7l GNU/Linux

$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 3 (v7l)
BogoMIPS        : 90.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae

Full information is the following.
warning.txt
system-info.txt

I noticed the 'HAVE_UNALIGNED_ACCESS' macro affects some many-bits calculation especially for
crypto.

$ find . -name '*.h' | xargs grep "UNALIGNED"
./ccan/config.h:#define HAVE_UNALIGNED_ACCESS 1
./external/libwally-core/src/config.h:#define HAVE_UNALIGNED_ACCESS 1
./external/libwally-core/src/ccan_config.h:#if HAVE_UNALIGNED_ACCESS

It means the following in my understanding. Right?
HAVE_UNALIGNED_ACCESS=0 --> pointers are aligned appropriately in advance.
HAVE_UNALIGNED_ACCESS=1 --> pointers may not be aligned. need check and re-align.

If my understanding is correct, the following logic is upside-down?
CURRENT: lightning/ccan/ccan/crypto/sha256/sha256.c

170 static bool alignment_ok(const void *p UNUSED, size_t n UNUSED)
171 {
172 #if HAVE_UNALIGNED_ACCESS
173         return true;
174 #else
175         return ((size_t)p % n == 0);
176 #endif
177 }

should be:

170 static bool alignment_ok(const void *p UNUSED, size_t n UNUSED)
171 {
172 #if HAVE_UNALIGNED_ACCESS
173         return ((size_t)p % n == 0);
174 #else
175         return true;
176 #endif
177 }

the above code affects the following process.

195                 /* Process full chunks directly from the source. */
196                 if (alignment_ok(data, sizeof(uint32_t)))
197                         Transform(ctx->s, (const uint32_t *)data);
198                 else {
199                         memcpy(ctx->buf.u8, data, sizeof(ctx->buf));
200                         Transform(ctx->s, ctx->buf.u32);
201                 }

Could you take a look at the codes and give me a comment?
Thanks in advance.

ccanlint core dumps if _info example contains a comment

This cost me about an hour before I figured out the cause (but not the real solution). I could see this issue turning away contributors, as they might have a ready made example on hand that they slam into their _info file which happens to contain some comments, and then ccanlint inexplicably loses its lunch. So it might be worth making ccanlint at least not core dump, and give a better hint about what might be going on.

How to reproduce the issue:

  • Edit any modules _info file which contains an example program, and add a comment into it.
  • Run ccanlint in the module.

Example:

scameron@sirius ~/github/ccan/ccan/a_star $ git diff
diff --git a/ccan/a_star/_info b/ccan/a_star/_info
index 2cfd941..25f1060 100644
--- a/ccan/a_star/_info
+++ b/ccan/a_star/_info
@@ -20,7 +20,7 @@
  * #include <string.h>
  * #include <stdlib.h>
  * #include <math.h>
- *
+ * /* What happens if you add a comment into an example? */
  * #include <ccan/a_star/a_star.h>
  *
  * static char maze[] =
scameron@sirius ~/github/ccan/ccan/a_star $ ulimit -c unlimited
scameron@sirius ~/github/ccan/ccan/a_star $ ../../tools/ccanlint/ccanlint -v
sh: 1: Syntax error: word unexpected
Segmentation fault (core dumped)
scameron@sirius ~/github/ccan/ccan/a_star $ ls core
ls: cannot access core: No such file or directory
scameron@sirius ~/github/ccan/ccan/a_star $ gdb ../../tools/ccanlint/ccanlint 
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ../../tools/ccanlint/ccanlint...done.
(gdb) run -v
Starting program: /home/scameron/github/ccan/tools/ccanlint/ccanlint -v
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
sh: 1: Syntax error: word unexpected

Program received signal SIGSEGV, Segmentation fault.
0x00000000004158ae in get_ported (ctx=0x63eb10, dir=0x63dad0 "/home/scameron/github/ccan/ccan/a_star", recurse=true, get_info=0x413f66 <get_or_compile_info>)
    at tools/depends.c:316
316         for (i = 0; deps[i]; i++) {
(gdb) bt
#0  0x00000000004158ae in get_ported (ctx=0x63eb10, dir=0x63dad0 "/home/scameron/github/ccan/ccan/a_star", recurse=true, get_info=0x413f66 <get_or_compile_info>)
    at tools/depends.c:316
#1  0x000000000041edbb in can_build (m=0x63eb10) at tools/ccanlint/tests/info_ported.c:24
#2  0x000000000040273b in run_test (n=0x636c48 <info_ported+72>, run=0x7fffffffde40) at tools/ccanlint/ccanlint.c:138
#3  0x00000000004046b3 in traverse_depth_first (n=0x636c48 <info_ported+72>, dir=DGRAPH_TO, fn=0x40263a <run_test>, data=0x7fffffffde40) at ccan/dgraph/dgraph.c:74
#4  0x000000000040461e in traverse_depth_first (n=0x6371c8 <objects_build+72>, dir=DGRAPH_TO, fn=0x40263a <run_test>, data=0x7fffffffde40) at ccan/dgraph/dgraph.c:71
#5  0x000000000040461e in traverse_depth_first (n=0x637248 <objects_build_without_features+72>, dir=DGRAPH_TO, fn=0x40263a <run_test>, data=0x7fffffffde40)
    at ccan/dgraph/dgraph.c:71
#6  0x000000000040461e in traverse_depth_first (n=0x637448 <tests_compile_without_features+72>, dir=DGRAPH_TO, fn=0x40263a <run_test>, data=0x7fffffffde40)
    at ccan/dgraph/dgraph.c:71
#7  0x000000000040461e in traverse_depth_first (n=0x6378e8 <tests_pass_without_features+72>, dir=DGRAPH_TO, fn=0x40263a <run_test>, data=0x7fffffffde40)
    at ccan/dgraph/dgraph.c:71
#8  0x000000000040475f in dgraph_traverse (n=0x7fffffffdf58, dir=DGRAPH_TO, fn=0x40263a <run_test>, data=0x7fffffffde40) at ccan/dgraph/dgraph.c:86
#9  0x000000000040392c in run_tests (all=0x7fffffffdf58, summary=false, deps_fail_ignore=false, m=0x63eb10, prefix=0x42571d "") at tools/ccanlint/ccanlint.c:574
#10 0x0000000000403a95 in test_module (all=0x7fffffffdf58, dir=0x638030 "/home/scameron/github/ccan/ccan/a_star", prefix=0x42571d "", summary=false, deps_fail_ignore=false)
    at tools/ccanlint/ccanlint.c:611
#11 0x0000000000403f62 in main (argc=1, argv=0x7fffffffe088) at tools/ccanlint/ccanlint.c:696
(gdb) info threads
  Id   Target Id         Frame 
* 1    Thread 0x7ffff7fcc740 (LWP 2473) "ccanlint" 0x00000000004158ae in get_ported (ctx=0x63eb10, dir=0x63dad0 "/home/scameron/github/ccan/ccan/a_star", recurse=true, 
    get_info=0x413f66 <get_or_compile_info>) at tools/depends.c:316
(gdb) quit
A debugging session is active.

    Inferior 1 [process 2473] will be killed.

Quit anyway? (y or n) y
scameron@sirius ~/github/ccan/ccan/a_star $ 

A possible solution would be to change the format of _info files to not require the example program to be inside a comment, but rather inside #ifdef CCAN_EXAMPLE_CODE ... #endif or something like that. That would have the added benefit that the example could be more easily extracted via cut and paste or :w, etc. without requiring any editing on the user's part, and the example could actually contain comments.

makefile build failed!

cc -g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wundef -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -DCCAN_STR_DEBUG=1 -I. -MMD -MP -MFccan/coroutine/coroutine.o.d -MTccan/coroutine/coroutine.o -c ccan/coroutine/coroutine.c -o ccan/coroutine/coroutine.o
ccan/coroutine/coroutine.c:63:2: error: array size is negative
BUILD_ASSERT(COROUTINE_MIN_STKSZ >= MINSIGSTKSZ);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./ccan/build_assert/build_assert.h:23:27: note: expanded from macro 'BUILD_ASSERT'
do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
^~~~~~~~~~~~~
1 error generated.
make: *** [ccan/coroutine/coroutine.o] Error 1

Subtitles will not download

I decided to check if youtube had some videos with subtitles and was pleased to find that it did. I set youtube-dl to work and it told me that the pages did not contain subtitles, yet I saw them with firefox so, I know they are there. I submitted this info here:
ytdl-org/youtube-dl#2526
but was unable to resolve the issue. I therefore think it is a bug.
I used both an older and a new, self compiled, version.

`tal_strdup(ctx, NULL)` returns uninitialized string

There is an edge case in tal_strdup that results in the return of an unterminated string to the caller.

tal_strdup(ctx, NULL)

#define tal_strdup(ctx, p) tal_strdup_(ctx, p, TAL_LABEL(char, "[]"))

tal_strdup_(ctx, NULL, "char[]")

ccan/ccan/tal/str/str.c

Lines 15 to 19 in cd56b18

char *tal_strdup_(const tal_t *ctx, const char *p, const char *label)
{
/* We have to let through NULL for take(). */
return tal_dup_arr_label(ctx, char, p, p ? strlen(p) + 1: 1, 0, label);
}

tal_dup_arr_label(ctx, char, NULL, 1, 0, "char[]")

ccan/ccan/tal/tal.h

Lines 407 to 410 in cd56b18

#define tal_dup_arr_label(ctx, type, p, n, extra, label) \
((type *)tal_dup_((ctx), tal_typechk_(p, type *), \
sizeof(type), (n), (extra), false, \
label))

(char *) tal_dup_(ctx, NULL, 1, 1, 0, false, "char[]")

ccan/ccan/tal/tal.c

Lines 814 to 854 in cd56b18

void *tal_dup_(const tal_t *ctx, const void *p, size_t size,
size_t n, size_t extra, bool nullok, const char *label)
{
void *ret;
size_t nbytes = size;
if (nullok && p == NULL) {
/* take(NULL) works. */
(void)taken(p);
return NULL;
}
if (!adjust_size(&nbytes, n)) {
if (taken(p))
tal_free(p);
return NULL;
}
/* Beware addition overflow! */
if (n + extra < n) {
call_error("dup size overflow");
if (taken(p))
tal_free(p);
return NULL;
}
if (taken(p)) {
if (unlikely(!p))
return NULL;
if (unlikely(!tal_resize_((void **)&p, size, n + extra, false)))
return tal_free(p);
if (unlikely(!tal_steal(ctx, p)))
return tal_free(p);
return (void *)p;
}
ret = tal_alloc_arr_(ctx, size, n + extra, false, label);
if (ret && p)
memcpy(ret, p, nbytes);
return ret;
}

p = NULL;
size = 1;
n = 1;
extra = 0;
nullok = false;
label = "char[]";
nbytes = 1;

if (false && NULL == NULL) ; // branch not taken

if (!adjust_size(&nbytes, 1)) ; // branch not taken

if (1 + 0 < 1) ; // branch not taken

if (taken(NULL)) ; // branch not taken

ret = tal_alloc_arr_(ctx, 1, 1 + 0, false, "char[]");

ccan/ccan/tal/tal.c

Lines 500 to 507 in cd56b18

void *tal_alloc_arr_(const tal_t *ctx, size_t size, size_t count, bool clear,
const char *label)
{
if (!adjust_size(&size, count))
return NULL;
return tal_alloc_(ctx, size, clear, label);
}

size = 1
count = 1
clear = false
label = "char[]"

if (!adjust_size(&size, 1)) ; // branch not taken

ret = /*return*/ tal_alloc_(ctx, 1, false, "char[]");

if (ret && NULL) ; // branch not taken
//	memcpy(ret, p, nbytes);
return ret;

So at the end of this call chain, we return a pointer to a buffer of size 1 whose sole byte has never been initialized, and we're claiming that this pointer points to a NUL-terminated string. That's bad! ☚ī¸

`tal_strndup(ctx, NULL, 1)` breaks contract

The contract for tal_strndup says:

ccan/ccan/tal/str/str.h

Lines 22 to 30 in cd56b18

/**
* tal_strndup - duplicate a limited amount of a string.
* @ctx: NULL, or tal allocated object to be parent.
* @p: the string to copy (can be take()).
* @n: the maximum length to copy.
*
* Always gives a nul-terminated string, with strlen() <= @n.
* The returned string will have tal_count() == strlen() + 1.
*/

However, when tal_strndup(ctx, NULL, n) is called with n being any non-zero integer, the returned string will have tal_count() equal to n + 1 (i.e., at least 2), but strlen() will be equal to zero. 2 != 0 + 1.

ccan/ccan/tal/str/str.c

Lines 27 to 30 in cd56b18

if (likely(p))
len = strnlen(p, n);
else
len = n;

It seems like this^ really should say len = 0; in the else branch.

JSON parser test failures

create-ccan-tree failed

Building ccan_depends, modfiles
Cleaning source tree
ccan_depends: Could not open ./..//ccan/--long/_info
Invalid ccan module '--long'?
Adding ccan/--long
modfiles: Getting canonical version of directory ccan/--long: No such file or directory
Adding licenses
Adding build infrastructure
Done. ccan source tree built in ab:

SIGBUS on OpenBSD sparc64

CLN at 5af9d19e9411833b0a584f0906221fa946911fa3

OS: OpenBSD 7.4
Arch: SPARC64
Network: signet
Compiler: GCC 8.4

CLN crashes soon after starting. I realize sparc64 is ancient but these logs may be useful?

2023-12-25T03:01:20.724Z INFO    lightningd: Server started with public key 02a004aeaf1815608a5e4f6a47c403fc2d183f562fe3c74572b20a1ba7720509f2, alias ORANGECHIPMUNK (color #02a004) and lightningd v23.11-79-g5af9d19-modded
2023-12-25T03:01:21.297Z DEBUG   lightningd: Adding block 175157: 000001032291091d00c466e51f5ecba7b8e8a64abb1b57e5627dae32bc30eee6

Program received signal SIGBUS, Bus error.
add (ctx=0xfffffef647cfc058, p=Unhandled dwarf expression opcode 0xf3
) at ccan/ccan/crypto/siphash24/siphash24.c:86
86                              add_64bits(ctx->v, *(const uint64_t *)data);
Current language:  auto; currently minimal


(gdb) backtrace
#0  add (ctx=0xfffffef647cfc058, p=Unhandled dwarf expression opcode 0xf3
) at ccan/ccan/crypto/siphash24/siphash24.c:86
#1  0x0000002fb6bb328c in siphash24_update (ctx=0xfffffef647cfc058, p=0xfffffef647cfc2b4, size=32) at ccan/ccan/crypto/siphash24/siphash24.c:116
#2  0x0000002fb6a6cd7c in outpoint_hash (out=0xfffffef647cfc2b4) at wallet/txfilter.c:38
#3  0x0000002fb6a6d118 in outpointfilter_matches (of=0x3278649c18, outpoint=0xfffffef647cfc2b4) at wallet/txfilter.c:48
#4  0x0000002fb6a76a8c in wallet_outpoint_spend (w=0x31df7a8b88, ctx=0x31df7cdb58, blockheight=Unhandled dwarf expression opcode 0xf3
) at wallet/wallet.c:4297
#5  0x0000002fb6a047c8 in topo_update_spends (topo=0x31df781428, b=0x31df7a56e8) at lightningd/chaintopology.c:928
#6  0x0000002fb6a04c1c in add_tip (topo=0x31df781428, b=0x31df7a56e8) at lightningd/chaintopology.c:985
#7  0x0000002fb6a05e60 in get_new_block (bitcoind=0x31df7a33d8, blkid=0xfffffef647cfc538, blk=0x31df76da68, topo=0x31df781428) at lightningd/chaintopology.c:1083
#8  0x0000002fb6a028dc in getrawblockbyheight_callback (
    buf=0x3278606a28 "\n\n{\"jsonrpc\":\"2.0\",\"id\":\"cln:getrawblockbyheight#34\",\"result\":{\"blockhash\":\"000001032291091d00c466e51f5ecba7b8e8a64abb1b57e5627dae32bc30eee6\",\"block\":\"000000207924475930b56b27b71520e9fcf0dd1de2fd5c126"..., toks=0x31df77b568, idtok=0x31df77b5b8, call=0x31df79b728) at lightningd/bitcoind.c:493
#9  0x0000002fb6a551fc in plugin_response_handle (plugin=0x31df77bba8, toks=0x31df77b568, idtok=0x31df77b5b8) at lightningd/plugin.c:660
#10 0x0000002fb6a58f08 in plugin_read_json_one (plugin=0x31df77bba8, want_transaction=Unhandled dwarf expression opcode 0xf3
) at lightningd/plugin.c:772
#11 0x0000002fb6a59210 in plugin_read_json (conn=Unhandled dwarf expression opcode 0xf3
) at lightningd/plugin.c:823
#12 0x0000002fb6bb4bb8 in next_plan (conn=0x31df7c13a8, plan=0x3278607188) at ccan/ccan/io/io.c:59
#13 0x0000002fb6bb525c in do_plan (conn=0x31df7c13a8, plan=0x31df7c13c8, idle_on_epipe=Unhandled dwarf expression opcode 0xf3
) at ccan/ccan/io/io.c:407
#14 0x0000002fb6bb52a4 in io_ready (conn=0x31df7c13a8, pollflags=Unhandled dwarf expression opcode 0xf3
) at ccan/ccan/io/io.c:417
#15 0x0000002fb6bb7520 in io_loop (timers=0x31df7e2528, expired=0xfffffef647cfcba0) at ccan/ccan/io/poll.c:453
#16 0x0000002fb6a278dc in io_loop_with_timers (ld=0x31df7df428) at lightningd/io_loop_with_timers.c:22
#17 0x0000002fb6a2d8f0 in main (argc=Unhandled dwarf expression opcode 0xf3
) at lightningd/lightningd.c:1334
(gdb) 

multiple definition of `_asort' - on musl libc

As I already mentioned in #66 here is the following error when compiling ccan e2d15a2 on Alpine Linux:

cc -g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wundef -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -DCCAN_STR_DEBUG=1 -I.  -MMD -MP -MFtools/ccanlint/ccanlint.d -MTtools/ccanlint/ccanlint tools/ccanlint/ccanlint.c tools/ccanlint/async.o tools/ccanlint/licenses.o tools/ccanlint/file_analysis.o tools/ccanlint/tests/tests_compile_coverage.o tools/ccanlint/tests/reduce_features.o tools/ccanlint/tests/objects_build_with_stringchecks.o tools/ccanlint/tests/objects_build.o tools/ccanlint/tests/depends_build_without_features.o tools/ccanlint/tests/info_documentation_exists.o tools/ccanlint/tests/depends_exist.o tools/ccanlint/tests/main_header_exists.o tools/ccanlint/tests/examples_run.o tools/ccanlint/tests/license_file_compat.o tools/ccanlint/tests/objects_build_without_features.o tools/ccanlint/tests/module_links.o tools/ccanlint/tests/headers_idempotent.o tools/ccanlint/tests/examples_relevant.o tools/ccanlint/tests/tests_exist.o tools/ccanlint/tests/license_exists.o tools/ccanlint/tests/main_header_compiles.o tools/ccanlint/tests/tests_pass.o tools/ccanlint/tests/examples_exist.o tools/ccanlint/tests/depends_build.o tools/ccanlint/tests/examples_compile.o tools/ccanlint/tests/depends_accurate.o tools/ccanlint/tests/tests_helpers_compile.o tools/ccanlint/tests/info_summary_single_line.o tools/ccanlint/tests/license_comment.o tools/ccanlint/tests/tests_pass_without_features.o tools/ccanlint/tests/info_exists.o tools/ccanlint/tests/tests_coverage.o tools/ccanlint/tests/tests_pass_valgrind.o tools/ccanlint/tests/info_ported.o tools/ccanlint/tests/module_builds.o tools/ccanlint/tests/info_compiles.o tools/ccanlint/tests/no_trailing_whitespace.o tools/ccanlint/tests/hash_if.o tools/ccanlint/tests/tests_compile.o tools/ccanlint/tests/license_depends_compat.o tools/ccanlint/tests/avoids_cpp_reserved.o ccan/asort/asort.o ccan/autodata/autodata.o ccan/dgraph/dgraph.o ccan/ilog/ilog.o ccan/lbalance/lbalance.o ccan/ptr_valid/ptr_valid.o ccan/strmap/strmap.o tools/manifest.o tools/tools.o tools/depends.o tools/compile.o tools/ccan_dir.o tools/gcov.o tools/read_config_header.o tools/doc_extract-core.o ccan/asort/asort.o ccan/err/err.o ccan/foreach/foreach.o ccan/hash/hash.o ccan/htable/htable.o ccan/list/list.o ccan/noerr/noerr.o ccan/opt/parse.o ccan/opt/usage.o ccan/opt/opt.o ccan/opt/helpers.o ccan/rbuf/rbuf.o ccan/read_write_all/read_write_all.o ccan/str/debug.o ccan/str/str.o ccan/take/take.o ccan/tal/tal.o ccan/tal/grab_file/grab_file.o ccan/tal/link/link.o ccan/tal/path/path.o ccan/tal/str/str.o ccan/time/time.o -lm -o tools/ccanlint/ccanlint
ccan/asort/asort.o: In function `_asort':
/home/jasan/src/ccan/ccan/asort/asort.c:99: multiple definition of `_asort'
ccan/asort/asort.o:/home/jasan/src/ccan/ccan/asort/asort.c:99: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:69: tools/ccanlint/ccanlint] Error 1

-d Option in Wiki

The wiki specifies a -d option for ccanlint.

So such option exists.

tal/path/path_join reads outside buffer with empty base string

When path_join is called with path_join(NULL, "", "foo"), the code reads 1 byte before the allocated return buffer:

51 len = strlen(base);
52 ret = tal_dup_arr(ctx, char, base, len, 1 + strlen(a) + 1);
53 if (!ret)
54 goto out;
55 if (ret[len-1] != PATH_SEP)
56 ret[len++] = PATH_SEP;

When len is 0, ret[len-1] reads 1 byte before the allocated return buffer.

musl libc: opt/usage.c:7:60: fatal error: sys/unistd.h: No such file or directory

In file included from ccan/opt/usage.c:5:0:
/mnt/hd2015c1/data/home/luke-jr/src/openwrt/LEDE-17.01/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/include/sys/termios.h:1:2: warning: #warning redirecting incorrect #include <sys/termios.h> to <termios.h> [-Wcpp]
 #warning redirecting incorrect #include <sys/termios.h> to <termios.h>
  ^
ccan/opt/usage.c:7:60: fatal error: sys/unistd.h: No such file or directory

licenses

Many (though not all) of the files in ccan just have a 1-line reference to the license file, without any copyright information (author/date). I'm no lawyer (I just happened to notice this while looking at porting a project which includes some code from ccan) but my understanding is that these might be required in order for the license grants (which are intended to be done under copyright law) to be valid. Could you take a look into this sometime please and check if anything needs to be done? Thanks.

Integration with clib

I've been working on a similar concept, called clib. Thoughts on working together and possibly allowing ccan modules to be installed with clib(1)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.