Skip to content

C API Seg Fault from OrtGetApiBase()->GetApi(ORT_API_VERSION);  #20283

Open
@Jon-Croz

Description

Describe the issue

Initializing ORT with the C API breaks during code execution... including the headers and initializing other ORT functions seems fine except for: OrtGetApiBase()->GetApi(ORT_API_VERSION);.

Here is a small code snippet (there is more code that runs fine, but is not attached).

#define FUNCTION_NAME "Main:"
#include "assert.h"
#include "onnxruntime_c_api.h"
#include "header.h"

int main(int argc, char** argv)
{
  #define ORT_ABORT_ON_ERROR(expr)             \
  do {                                                                    \
    OrtStatus* onnx_status = (expr);                      \
    if (onnx_status != NULL) {                                 \
      const char* msg = g_ort->GetErrorMessage(onnx_status); \
      fprintf(outp, "%s\n", msg);                             \
      g_ort->ReleaseStatus(onnx_status);               \
      abort();                                                            \
    }                                                                        \
  } while (0);

  /* Problem is here... entering the ORT API ... */
  const OrtApi* g_ort = OrtGetApiBase()->GetApi(ORT_API_VERSION);

 }

Urgency

This is urgent for ONNX runtime C API users. The onnxruntime-linux version is 1.17.1

Target platform

Rocky Linux 9.3 , kernel: Linux 5.14.0

Build script

CC = gcc
CFLAGS = -Wall -ansi -ffast-math -O3 -Wunused
LDFLAGS += -L/home/ONNX/onnx/onnxruntime-linux-x64-1.17.1/lib -lonnxruntime
LDFLAGS += '-Wl,-rpath=/home/ONNX/onnx/onnxruntime-linux-x64-1.17.1/lib'
CFLAGS += -I/home/ONNX/onnx/onnxruntime-linux-x64-1.17.1/include
CFLAGS += -DOPEN_MP
CFLAGS += -fopenmp
LDFLAGS += -fopenmp

Error / output

===================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= RANK 0 PID 910389 RUNNING AT n015
= KILLED BY SIGNAL: 11 (Segmentation fault)

Visual Studio Version

No response

GCC / Compiler Version

13.1.0

Metadata

Assignees

No one assigned

    Labels

    apiissues related to all other APIs: C, C++, Python, etc.buildbuild issues; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions