Skip to content

ccan: Update vendored ccan to commit 7c38521d, which includes rustyrussell/ccan#128 and rustyrussell/ccan#130#9237

Open
nGoline wants to merge 2 commits into
ElementsProject:masterfrom
nGoline:update-ccan-pollhup
Open

ccan: Update vendored ccan to commit 7c38521d, which includes rustyrussell/ccan#128 and rustyrussell/ccan#130#9237
nGoline wants to merge 2 commits into
ElementsProject:masterfrom
nGoline:update-ccan-pollhup

Conversation

@nGoline

@nGoline nGoline commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

On macOS, failed connect() calls return POLLHUP|POLLERR or POLLOUT|POLLHUPfrom poll, and the socket error is set to ECONNREFUSED. Previously ccan's io_poll hardcoded EBADF in the POLLHUP case, causing misleading Bad file descriptor errors. The fix reads SO_ERROR from the socket to surface the real errno.

Also fixes update-ccan Makefile target:

  • Use git rev-parse --short HEAD instead of git describe (ccan has no tags)
  • Remove reference to ccodearchive.net following rustyrussell/ccan@efd4838

Closes #9236.

The test-level fix for test_networkevents (PR #9140) is still needed but will require a different approach now that the underlying error is correct.

Changelog-None

@nGoline nGoline requested review from ddustin and sangbida June 18, 2026 18:34
@nGoline nGoline added this to the v26.09 milestone Jun 18, 2026
Comment thread ccan/ccan/json_out/json_out.c Outdated

if (json_escape_needed(str, len)) {
e = json_escape_len(NULL, str, len);
e = json_escape(NULL, str);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm something weird happened here. This was changed with #9098 in commit 6664d34, but ccan wasn't updated.

Looks like it was a useful check but not critical.

@sangbida did this solve a particular issue you saw? If so let's get this fixed upstream in ccan so we stay in sync with it.

@sangbida sangbida Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember it being related to this previous commit here 400f97d. Rusty used json_out_addstrn instead of json_add_str_fmt(result, fieldname, "%.*s", (int)value_len, value);
for better efficiency but injson_out_addstrnthe escape path wasn't using the length that was passed in. The old path did json_add_str_fmt("%.*s", len, ...) + json_escape_len, so escaping respected the explicit length. json_out_addstrn's escape branch instead called json_escape(NULL, str), which uses strlen.

That broke getlog becuase log messages live in a ring buffer and are not NUL-terminated at loglen, so the json_add_stringn(info->response, "log", log, loglen) call in lightningd/log.c hands json_out_addstrn a non-terminated string. When a log line contains an escapable character, strlen reads past loglen into adjacent ring-buffer memory and emits invalid UTF-8.

@sangbida sangbida Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a PR to add this into the ccan repo: rustyrussell/ccan#130

Thanks for catching that @ddustin @nGoline!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Updated ccan to the latest version containing your commit @sangbida.

Are we good to merge @ddustin?

Update update-ccan recipe to use ccan's commit instead of tag since ccan's home moved to github

Changelog-None
@nGoline nGoline force-pushed the update-ccan-pollhup branch from 6afd4aa to 8c71917 Compare June 19, 2026 10:35
- readme: remove reference to old domain and point to rustyrussell/ccan
@nGoline nGoline force-pushed the update-ccan-pollhup branch from 8c71917 to fb93364 Compare June 19, 2026 10:39
@nGoline nGoline changed the title ccan: Update vendored ccan to commit 7c38521d, which includes rustyrussell/ccan#128 ccan: Update vendored ccan to commit 7c38521d, which includes rustyrussell/ccan#128 and rustyrussell/ccan#130 Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ccan: update ccan to fix macOS POLLHUP socket error handling

3 participants