#
#asahi-dev · 2024-03-30 11:27
leiosad thing that "(transfer full)", "(transfer none)" and so on doc markup doesn't really help with anything much in C side beyond being able to see it as a documentation to know what to do with it in C, but they are used to make bindings memory safe at least
#asahi-dev · 2024-03-30 11:25
leiobut I can't find the old revisions anymore (and it doesn't matter)
#asahi-dev · 2024-03-30 11:25
chadmedso we need to guard all that recursive crap underneath
#asahi-dev · 2024-03-30 11:25
leioand I assume it crashed before because you g_autoptr as_section while wp_properties_get doesn't hand a string that you own
#asahi-dev · 2024-03-30 11:25
chadmedthe idea is to not do that, and parse the entire file as a value with a specified key name in WpProperties
#asahi-dev · 2024-03-30 11:24
chadmedthe issue there is that without guarding behind if (as_section) it will try to parse the first token as a key then look for a value off that key
#asahi-dev · 2024-03-30 11:23
chadmedthats what i had initially without the strdup
#asahi-dev · 2024-03-30 11:17
leiotl;dr: I think you need `section.name = as_section ? g_strdup (as_section) : wp_spa_json_parse_string (tmp);`
#asahi-dev · 2024-03-30 11:17
leiootherwise you'll have a UAF (use after free) down the line when the section you made gets deleted and the wp_properties stuff accesses it, or e.g. properties get reloaded and the section is accessed
#asahi-dev · 2024-03-30 11:16
chadmedlet me try and fix the lua side first
#asahi-dev · 2024-03-30 11:16
chadmedhmm okay
#asahi-dev · 2024-03-30 11:16
leioso I THINK you need to g_strdup it instead of casting away the const
#asahi-dev · 2024-03-30 11:16
leiochadmed: the thing is that wpa_spa_json_parse_string gives you a char* that the caller will own (transfer full), while wp_properties_get gives you a string that you do not own (transfer none)
#asahi-dev · 2024-03-30 11:12
chadmedaha ive narrowed it down to the lua api
#asahi-dev · 2024-03-30 11:09
chadmedthe only issue im having now is that the parser returns an empty json object to me
#asahi-dev · 2024-03-30 11:06
chadmedthe original function also just assigns a string to section.name via wp_spa_json_parse_string(tmp)
#asahi-dev · 2024-03-30 10:58
leiocasting away the const is sort of a give-away of problem, I think?
#asahi-dev · 2024-03-30 10:57
leiowp_spa_json_parse_string is (transfer full), so that path does own it; so if section gets deallocated, it frees the strict that the underlying hashmap in wp_properties stuff owns
#asahi-dev · 2024-03-30 10:56
leionot sure it's OK to assign a string to section.name without owning it, though
#asahi-dev · 2024-03-30 10:54
leiowp_properties_get is (transfer none), so, uh, nevermind :)
#asahi-dev · 2024-03-30 10:53
leiothough some no_frags case in the same file that's used the same doesn't concern itself about it either, so I guess it might be fine in your case too?
#asahi-dev · 2024-03-30 10:50
leiochadmed_
#asahi-dev · 2024-03-30 10:49
leioif that is true, you could make it a g_autoptr and then go through g_steal_pointer when passing it on to section.name
#asahi-dev · 2024-03-30 10:47
leiothough not the case if any of the error early returns happen
#asahi-dev · 2024-03-30 10:47
leioah, no, if it's set, it gets passed on to section.name, so that's intended presumably, nvm
#asahi-dev · 2024-03-30 10:46
leiodoesn't as_section leak now in some cases? Though only if wp_properties_get returns something that needs freeing and I don't know which it is
#asahi-dev · 2024-03-30 08:37
chadmedfixed it happy days
#asahi-dev · 2024-03-30 08:32
chadmedhmph its glib clearing the pointer to the object
#asahi-dev · 2024-03-30 08:13
chadmedmixi: well thats embarrassing :p thanks
#asahi-dev · 2024-03-30 08:11
mixichadmed_: not sure about why the 5db7a43a one segfaults, but you are not assigning to as_section in 02786b712d02
#asahi-dev · 2024-03-30 07:42
chadmed_commit 5db7a43a now :p
#asahi-dev · 2024-03-30 07:37
chadmed_its just this one call, the commits above it make their calls to wp_properties_get() just fine
#asahi-dev · 2024-03-30 07:36
chadmed_and if we dont have this fixed by approximately now then its not going to make it into a release before fedora 40 drops
#asahi-dev · 2024-03-30 07:36
chadmed_for context upstream want the disk loading api implemented in a very specific (and imo silly) way and this is necessary based on suggestions made in MR 628
#asahi-dev · 2024-03-30 07:35
chadmed_ugh i have the flu and my brain has stopped working. can someone look at https://gitlab.freedesktop.org/chadmed/wireplumber/-/tree/sw-dsp/from-disk?ref_type=heads and tell me why the call to wp_properties_get() in e179d136 specifically causes a segfault
#asahi-dev · 2024-03-29 14:55
jannegyes, but it is m3 only. the cursed 13.5 FW which shipped with the devices released last year uses ascwrap-v4 but with 14.x "ascwrap-v6" is in the compatible string
#asahi-dev · 2024-03-29 14:44
kettenisyou mean if you upgrade to macOS 14 firmware the ascwrap-v4s become ascwrap-v6s?
#asahi-dev · 2024-03-29 14:41
jannegnot the most pressing issue. first fixing the HV and then finding out how ascwrap-v6 differs from ascwrap-v4 (that's a macOS 14 thing)
#asahi-dev · 2024-03-29 14:18
kettenisbut that might cause isses further down the line when we actually try to shutdown clusters
#asahi-dev · 2024-03-29 14:17
kettenisI soppose m1n1 could repair this by starting the first e-core and parking the p-core
#asahi-dev · 2024-03-29 14:15
jannegi.e. a splitted performance cluster. not saying it breaks anything but it is unintuitive
#asahi-dev · 2024-03-29 14:13
jannegI need linux user-space but it looks like we might end up with p-core, 4 * e-core, 3 * p-core
#asahi-dev · 2024-03-29 14:07
kettenisthe DT doesn't really have CPU numbers; just the MPIDR register values
#asahi-dev · 2024-03-29 14:06
jannegit boots without HV (cpu numbers don't match with DT though). it looks like a timer issue in m1n1's hypervisor
#asahi-dev · 2024-03-29 14:02
kettenisother arm64 hardware that is
#asahi-dev · 2024-03-29 14:02
kettenisjanneg: I'm pretty sure there is other hardware that boots on the CPU that isn't the first one listed in the device tree
#asahi-dev · 2024-03-29 12:46
jannegno, seems to be a timer issue with the HV
#asahi-dev · 2024-03-29 11:34
jannegunsure if this is the problem
#asahi-dev · 2024-03-29 11:09
jannegDocumentation/arch/arm64/booting.rst only speaks about the primary CPU and at least based kernel messages it seems to assume that this is cpu0
#asahi-dev · 2024-03-29 11:07
jannegoh, the joys of not booting with cpu0. m1n1 and hypervisor seems to work now but linux doesn't seem to be happy

plus ›