Repository navigation
Conversation
I found this while looking at how keyboard shortcuts for actions are stored in ~/.config/nemo/actions-tree.json. If I read the code correctly, when the basename doesn't end in ".nemo_action", the function returns copy, which is declared g_autofree, so the string is freed on return. The caller, parse_item() in nemo-action-manager.c, keeps the result in a g_autofree lookup_uuid and would then free it a second time. In my tests, an "action" entry whose uuid has no ".nemo_action" suffix makes Nemo abort on startup with "free(): double free detected in tcache 2". That includes the "sample@untracked" form shown in action-layout-editor/actions-tree.md. I saw it with Nemo 6.8.4 from my distribution and with a local build of master, and gdb points at the g_autofree cleanup of lookup_uuid in parse_item(). Returning g_steal_pointer (©) seems to be enough: with this change, the same layouts no longer crash in my build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
I was looking at how to give a custom action a keyboard shortcut, and found that it goes through
~/.config/nemo/actions-tree.json. While trying a few layouts by hand, I noticed that Nemo crashes on startup when anactionentry has auuidthat doesn't end in.nemo_action. That includes thesample@untrackedform shown inaction-layout-editor/actions-tree.md:If I read the code correctly,
nemo_make_action_uuid_for_path()returnscopyin that case, butcopyis declaredg_autofree, so the string is freed on return. The caller,parse_item(), keeps the result in ag_autofree lookup_uuidand would then free it a second time. With a.nemo_actionsuffix the function returns a new string fromg_strndup(), which would explain why layouts saved by the layout editor don't hit this, since it seems to use the file name with its extension.This PR changes that one line to
return g_steal_pointer (©);.How to reproduce:
(This replaces any existing
actions-tree.json.)How I tested it: on one machine (CachyOS, Hyprland), with the Nemo 6.8.4 package from my distribution and a local debug build of master (
bf7e43f6). To build it here I had to skip the GObject introspection step, becauseg-ir-scannerisn't installed. That change is not part of this PR. Each run used its own D-Bus session and temporaryXDG_CONFIG_HOME/XDG_DATA_HOME, so my real config wasn't involved. I started Nemo 3 times per layout and counted it as fine when it was still running after 5 seconds:actions-tree.jsonuuidwith.nemo_actionuuidwithout suffixuuidliketest-b@untrackeduuidwith.nemo_actionOn master without the change, gdb shows the second free here (trimmed):
meson testgives the same results with and without the change in my environment: 2 tests pass, andCopy testfails whileSearch Engine testandDirectory Async testtime out, which I think comes from my setup rather than from Nemo.What I didn't test: the shortcuts themselves, or the layout editor. I only checked that Nemo starts.
A related note on the docs: with this fix, the debug log shows that a
uuidwithout the suffix (test-b) is now found and added to the menu, but the@untrackedform is reported asMissing action ... ignored. Readingactions-tree.mdnext to the code, a few things also don't seem to match any more: it gives the path~/.config/nemo/actions/actions-tree.jsonwhile the code reads~/.config/nemo/actions-tree.json, the editor seems to write the file name with its.nemo_actionextension as theuuid, and theacceleratorkey isn't mentioned. I'd be happy to send a separate PR for that if it's useful, or to leave it if you'd rather handle it.If I misread something here, I'd be glad to know, and I'm fine with closing this.
🤖 Generated with Claude Code