Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9230775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:54:15+00:00 2026-06-18T05:54:15+00:00

I have an application written in Python. The application calls some functions in the

  • 0

I have an application written in Python.

The application calls some functions in the dll (using ctypes) that calls some functions from the python C API to load and run some functions in a (different) python module. This causes WindowsError: exception: access violation reading 0x00000004 Some cout debugging tells me that the access violation happens on a call to the Python C API.

I know the DLL successfully loads the python module, running to completion when I test it as a stand alone .exe but when it is run from the python application it gives this access violation error.

I first though that maybe I should use Py_NewInterpreter in the DLL to create a new separate space for these python module functions to run. This would seem convienent as there is no need for the application and the modules runs by the DLL to share any data.
http://docs.python.org/2/c-api/init.html#Py_NewInterpreter

However my initial tests with Py_NewInterpreter have proved unsuccessful simply making further errors and crashing.

So my question is how should I implement this/what do I need to do make the DLL load of the python modules work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:54:16+00:00Added an answer on June 18, 2026 at 5:54 am

    This looks like dereferencing a null pointer, i.e. a pointer to a structure/class is null and you are reading a subobject at offset 4. Sprinkle a few assert()s throughout your code to make sure you don’t miss any null pointer. Note also that the Python C API regularly returns null in case of an exception.

    That said, you have a Python program importing a DLL via ctypes. This DLL in turn embeds a Python interpreter via Python’s C API. Right? If I’m not mistaken, that effectively gives you two interpreter instances in one process. The problem there is that any global objects are shared between the two and that this might not be coordinated.

    What I would try is to write a proper Python (wrapper) module instead of using ctypes to import the DLL. However, there’s another thing that I would do in parallel and that is to ask on the Python user mailinglist, whether this setup can work or not and why. There is also a news gateway in case you prefer that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application written in Python 2.7 that reads user's file from the
I have written an application using Python 2.7 and Tkinter that edits *.docx files.
I have an application written using C++ Builder 5 that uses the TDocument class.
I have written a logging application in Python that is meant to start at
I'm playing around with python and have written an application that generates a lot
I have an application written in Python that's writing large amounts of data to
I have an application written in Python. It collects and parses data from certain
I have an application written in python that logs errors in a log file,
I have a small application written in Python using Flask. Right now I'm running
if I have an application that is written part in Python and has dependencies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.