Previous changes were transforming the error path as early return,
leaving a potential indentation level for each commit that could be
removed. This commit is removing them.
No functional changes.
Split the normal path and error path and move the release behind the
error label to remove the handling of the `b_ok` state in the normal
path.
Since returning an error only makes the processing forward to the next
extension to be run, and doesn't fail completely, the label is named
"discard" to signal it will only discard the current extension.
Previous changes were transforming the error path as early return,
leaving a potential indentation level to be removed. This commit is
removing it.
No functional changes.
Previous changes were transforming the error path as early return,
leaving a potential indentation level for each commit that could be
removed. This commit is removing them.
No functional changes.
Use a player listener per extension to signal input changes instead of
relying on the UI to supply any new input change. This is using one
listener per extension so that we can remove it when deleting the
extension and be signalled of the first input when attaching the
listener the first time.
Fixes#22585
For now, we don't have any other reason to provide a different logger
than the extension one, especially since we mostly want to convert the
use cases.
There is a superfluous single nested if in the nesting else. The commit
also changes the code style to match new code for the lines that are
deindented.
The private sys type was extension_sys_t because that was the type
required by the structure. Now that it's a void pointer, we can rename
it to a more suitable name that can be found from a debugguer and
represent what the private implementation provides.
Refs #18033
Every controls are modifying an extension and require the extension to
be non-null as first parameter. Instead of forwarding the extension to
the va_list, extract it as first parameters unconditionnally.
This prepares some work to replace the pf_control callback by dedicated
operations and start reworking some code style along the way.
The lua interrupt will get cleaned when reaching Close_Extension through
if (sys->L)
{
lua_close(sys->L);
vlclua_fd_cleanup(&sys->dtable);
}
However, the call to lua_ExtensionDeactivate when reaching a
CMD_DEACTIVATE will also close the lua state and reset the sys->L to
NULL, preventing the previous snippet from cleaning the interrupt and
resulting in memory leaks.
Direct leak of 120 byte(s) in 3 object(s) allocated from:
#0 0x7f2a27cbfa89 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x7f2a2725f870 in vlc_interrupt_create ../../src/misc/interrupt.c:61
#2 0x7f29eea1d997 in vlclua_fd_init ../../modules/lua/libs/net.c:503
#3 0x7f29ee9e9d6e in GetLuaState ../../modules/lua/extension.c:805
#4 0x7f29ee9ec360 in lua_ExecuteFunctionVa ../../modules/lua/extension.c:896
#5 0x7f29ee9eca25 in lua_ExecuteFunction ../../modules/lua/extension.c:874
#6 0x7f29ee9f234d in Run ../../modules/lua/extension_thread.c:296
#7 0x7f2a2609ebb4 (/usr/lib/libc.so.6+0x85bb4)
If we try to also clean the interrupt from there, we might also reach
use-after-free because of races between the extension thread and the
client thread.
==457157==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000069661 at pc 0x7f3894c5f648 bp 0x7ffc0f0e3bc0 sp 0x7ffc0f0e3bb0
WRITE of size 1 at 0x604000069661 thread T0
#0 0x7f3894c5f647 in vlc_interrupt_kill ../../src/misc/interrupt.c:181
#1 0x7f3891329c40 in Close_Extension ../../modules/lua/extension.c:155
#2 0x7f389497d22e in module_unneed ../../src/modules/modules.c:305
#3 0x55b734884085 in OpenIntf ../../test/modules/lua/extension.c:95
#4 0x7f389497b12e in generic_start ../../src/modules/modules.c:275
#5 0x7f389497ccb5 in vlc_module_load ../../src/modules/modules.c:243
#6 0x7f389497d073 in module_need ../../src/modules/modules.c:286
#7 0x7f389499bd1d in intf_Create ../../src/interface/interface.c:172
#8 0x7f389499c9aa in libvlc_InternalAddIntf ../../src/interface/interface.c:267
#9 0x7f3895550b22 in libvlc_add_intf ../../lib/playlist.c:41
#10 0x55b73488358c in main ../../test/modules/lua/extension.c:127
#11 0x7f3893a3c78f (/usr/lib/libc.so.6+0x2378f)
#12 0x7f3893a3c849 in __libc_start_main (/usr/lib/libc.so.6+0x23849)
#13 0x55b7348836e4 in _start (/home/janniaux/Projects/videolabs/vlc/build-asan/test/test_modules_lua_extension+0x36e4)
0x604000069661 is located 17 bytes inside of 40-byte region [0x604000069650,0x604000069678)
freed by thread T8 (vlc-lua-ext) here:
#0 0x7f38956be672 in __interceptor_free /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:52
#1 0x7f389132cd5d in lua_ExtensionDeactivate ../../modules/lua/extension.c:642
#2 0x7f389132ec83 in Run ../../modules/lua/extension_thread.c:331
#3 0x7f3893a9ebb4 (/usr/lib/libc.so.6+0x85bb4)
Removing the closing of sys->L in lua_ExtensionDeactivate and leaving it
after the vlc_join() in Close_Extension ensure it will get called at
some point and called only once.
The extension were leaking the CMD_DEACTIVATE on close and not waiting
for executing it before closing. There were also issues when closing an
already closing extension, and then by extension opening a closing
extension.
This commit better tracks the state to handle those intertwined cases
while preventing deadlocks.
This makes it consistent with all the other uses of such defines in
the source code, which are tested for their existence rather than the
actual value.
Services discovery media were displayed via the old playlist, which allowed to
display their tree.
The new playlist is not a tree, but a list, so it can't be used to display
services discovery trees. This lua API is only used from cli.lua, and we
consider it's not worth it to implement this feature for now, so just remove
it.
Signed-off-by: Thomas Guillem <thomas@gllm.fr>