Skip to content

Conversation

@songgot
Copy link
Contributor

@songgot songgot commented Dec 3, 2025

Release builds often define the compile option -DG_DISABLE_ASSERT for performance optimization. When this option is enabled, the g_assert(condition) macro is replaced by a no-op by the preprocessor.

@songgot songgot force-pushed the remove_g_assert branch 3 times, most recently from d4ffb8e to c371fbf Compare December 4, 2025 00:12
@songgot songgot force-pushed the remove_g_assert branch 2 times, most recently from fcb8e67 to 18ee9bf Compare December 4, 2025 00:54
@songgot songgot marked this pull request as ready for review December 4, 2025 00:58
G_LOCK (nns_native_lock);
g_assert (g_nns_is_initialized);

if (!g_nns_is_initialized) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if (g_nns_is_initialized) {
  data_path = g_files_dir;
} else {
  _ml_loge ("NNStreamer native library is not initialized.");
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. And I wll add const.

 const char *data_path = NULL;

g_assert (pipe_info->jvm);
if (!pipe_info->jvm) {
_ml_loge ("Failed to get Java VM.");
nns_destroy_pipe_info (pipe_info, env);
Copy link
Collaborator

@jaeyun-jung jaeyun-jung Dec 4, 2025

Choose a reason for hiding this comment

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

You called nns_destroy_pipe_info() before creating all params (e.g., pipe_info->cls tensors_data_cls_info tensors_info_cls_info).
This causes null-ptr exception.
I suggest just removing this line, handling all error case is too complex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will fixe code like below.

pipe_info = g_new0 (pipeline_info_s, 1);
  g_return_val_if_fail (pipe_info != NULL, NULL);

  (*env)->GetJavaVM (env, &pipe_info->jvm);
  if (!pipe_info->jvm) {
    _ml_loge ("Failed to get Java VM.");
    g_free (pipe_info);
    return NULL;
  }

  pipe_info->pipeline_type = type;
  pipe_info->pipeline_handle = handle;
  pipe_info->element_handles =
      g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
      nns_free_element_data);
  g_mutex_init (&pipe_info->lock);
  pthread_key_create (&pipe_info->jni_env, NULL);

Release builds often define the compile option -DG_DISABLE_ASSERT
for performance optimization. When this option is enabled, the
g_assert(condition) macro is replaced by a no-op by the preprocessor.

Signed-off-by: hyunil park <[email protected]>
@myungjoo myungjoo merged commit 43b1ec1 into nnstreamer:main Dec 5, 2025
11 checks passed
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.

3 participants