Skip to content

No so_instance cleanup can be done if PacketDrill test fails #64

Description

@AmPaschal

Hi,

I am working with using PacketDrill to test some network stacks using a shared object file.
I just noticed that when a test line in the PacketDrill script fails, the application exits without calling the free() function in the shared object file.

At the conclusion of each test, state_free (defined in run.c:122) is called and this frees the netdev and packet buffers and calls the free function in the so_instance where subsequent buffers in the shared object file can be freed.

	close_all_fds(state);

	netdev_free(state->netdev);
	packets_free(state->packets);
	code_free(state->code);

	if (state->wire_client)
		wire_client_free(state->wire_client);

	if (state->so_instance)
		so_instance_free(state->so_instance);

In run_system_call.c:3338, If an error occurs, the die function is called

die("%s:%d: runtime error in %s call: %s\n",
	  state->config->script_path, event->line_number,
	  syscall->name, error);
free(error);

And in the implementation of die in logging.c, no function is called to free the state

extern void __attribute__((noreturn)) die(char *format, ...)
{
	va_list ap;

	va_start(ap, format);
	vfprintf(stderr, format, ap);
	va_end(ap);

	run_cleanup_command();

	exit(EXIT_FAILURE);
}

As a result, when an error occurs during a test, the cleanup is not done completely.

Is this an expected behavior? If I want to call a function on my shared object file at the failure of each test, does the current PacketDrill implementation provide any support?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions