Skip to content

Python: getting core dumped on import #4622

@stefanmaak

Description

@stefanmaak

What version of OR-Tools and what language are you using?
Version: 9.12
Language: Python3.12.3

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
I try to use the CP solver (I fail importing from SAT)

What operating system (Linux, Windows, ...) and version?
Linux (Ubuntu)

What did you do?
Steps to reproduce the behavior:
I get a core dump while importing ortools modules in a specific context ,i.e., after doing other imports.
I broke it down to the following minimal example:

  1. create a python environment (i am using python3 -m venv) with only gpcio-tools and ortools installed:
Package         Version
--------------- -----------
absl-py         2.2.2
grpcio          1.71.0
grpcio-tools    1.71.0
immutabledict   4.2.1
numpy           2.2.4
ortools         9.12.4544
pandas          2.2.3
pip             24.0
protobuf        5.29.4
python-dateutil 2.9.0.post0
pytz            2025.2
setuptools      78.1.0
six             1.17.0
tzdata          2025.2
  1. run this python script:
import grpc_tools.protoc
# uncommenting the following line causes bad_alloc instead of invalid pointer
import ortools
print("importing ortools.sat.python.cp_model")
import ortools.sat.python.cp_model
print("Finished importing all modules.")

What did you expect to see
A successful import.

What did you see instead?

importing ortools.sat.python.cp_model
munmap_chunk(): invalid pointer
Aborted (core dumped)

Make sure you include information that can help us debug (full error message, model Proto).

Anything else we should know about your project / environment
I created this example by listing all loaded modules in python before the critical import happened. Then I deleted them sequentially without the error disappearing. In the real project the import of grpc-related modules happens because is use sila2 (is on pip).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions