Ctype Windows access violation reading 0x733B7359

Question:

I use Ctype in my Django project but when I use this method :

def requete_smartphone(self, bande, debut_a, debut_m, debut_j, fin_a, fin_m, fin_j, sens, fvitesse, fstat, affmes,
                       min, max, moyenne, ecart, algofusion, s_route, vitesse, s_capteurs, s_typeveh, s_marque,
                       s_modele, s_immatriculation, s_pseudo, ecart_moyenne, nombre):
    """ Permet de faire la requete smarphone avec tout les paramètre qu'elle demande

    Paramètres :
    Les même que pour la DLL, suivre ce qui est écrit sur la fiche de la DLL

    Renvoie
    """
    bande = str.encode(bande)
    debut_a = int(debut_a)
    debut_m = int(debut_m)
    debut_j = int(debut_j)
    fin_a = int(fin_a)
    fin_m = int(fin_m)
    fin_j = int(fin_j)
    sens = str.encode(sens)
    fvitesse = str.encode(fvitesse)
    fstat = str.encode(fstat)
    affmes = str.encode(affmes)
    min = str.encode(min)
    max = str.encode(max)
    moyenne = str.encode(moyenne)
    ecart = str.encode(ecart)
    algofusion = str.encode(algofusion)
    s_route = str.encode(s_route)
    vitesse = float(vitesse)
    s_capteurs = str.encode(s_capteurs)
    s_typeveh = str.encode(s_typeveh)
    s_marque = str.encode(s_marque)
    s_modele = str.encode(s_modele)
    s_immatriculation = str.encode(s_immatriculation)
    s_pseudo = str.encode(s_pseudo)
    ecart_moyenne = float(ecart_moyenne)
    nombre = str.encode(nombre)
    print("c1")
    DLLFunction = self.libraryBase.requete_smartphone
    print("c2")
    DLLFunction.argtypes = [c_char, c_int, c_int, c_int, c_int, c_int, c_int, c_char, c_char, c_char, c_char,
                            c_char, c_char, c_char, c_char, c_char, c_char_p, c_float, c_char_p, c_char_p, c_char_p,
                            c_char_p, c_char_p, c_char_p, c_float, c_char]
    print("c3")
    DLLFunction.restype = c_bool
    print("c4")
    resultFunction = DLLFunction(bande, debut_a, debut_m, debut_j, fin_a, fin_m, fin_j, sens, fvitesse, fstat, affmes, min, max, moyenne, ecart, algofusion, s_route, vitesse, s_capteurs, s_typeveh, s_marque, s_modele, s_immatriculation, s_pseudo, ecart_moyenne, nombre)

    return resultFunction

Sometimes I have this error : OSError: exception: access violation reading 0x733B7359
Sometimes it’s 0x733B7359.
It’s possibly a problem with my argument, I don’t know if .encode(‘utf-8’) it’s really the best method.

Asked By: Nitner

||

Answers:

I find the problem :
It’s wasn’t my DLL and when I search in the method requete_smartphone in C. In this method all my c_char was use like a integer and use in array (for exemple array[bande] and my encode of c_char was in UTF-8, so when array[bande] try to point to array in index 1, with the encode he point to array in index 49. So I change DLL to have integer.

Answered By: Nitner
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.