Docker container exited (139) and logs double free or corruption (out)

I am running an application that extracts barcodes from images with the pyzbar module. When running the application from my local machine with the command line, there is no issue and the barcode can be extracted. Inside the docker container, I can extract other barcodes/qrcodes just fine. However, they are not necessarily urls. In the error case, the barcode to extract is a link. When running the same flask server inside a docker container, the container exits with 139 and prints double free or corruption (out) . Interesting is also,

After some digging, this seems to be a dependency issue. However, I have no clue which dependency is missing inside my docker container. I tried to troubleshoot with help online, but could not get further. Any help/pointers are highly appreciated! Thanks :slight_smile:

Docker Container

FROM pytorch/pytorch:latest
FROM python:3.8.3
#centOS base image
RUN apt-get update 
#RUN -H pip3 install --upgrade pip
RUN python3 -m pip install --upgrade pip
RUN pip install waitress flask boto3 pillow pyzbar

RUN apt-get update && \
    apt-get install -y build-essential libzbar-dev && \
    apt-get install zbar-tools 

WORKDIR /app
COPY . .

EXPOSE 3105

ENV FLASK_APP=app.py
ENV FLASK_DEBUG=1
CMD ["flask", "run", "--host", "0.0.0.0", "--port", "3105"] 
#CMD ["python", "app.py"]

Code that I am running

from flask import Flask, jsonify
from flask import request
from waitress import serve
from extract_barcodes import extract_barcodes


app = Flask(__name__)
app.config["DEBUG"] = True
app.secret_key = 'super secret key'
app.config['SESSION_TYPE'] = 'filesystem'



@app.route('/api/v1/qrscan', methods=['GET','POST'])
def qrscan():
    if request.method =="GET":
        return '''<h1>Qr scanner to get qr/bar codes from images</h1>
        <p>Send your images Cutie.</p>'''
    if request.method == "POST":
        sent_json=request.get_json()

        dummy_bucket='BLUB'
        dummy_file_path='KEY'
        
        compression_rates=[70,90]
        
        for item in sent_json:
            file_path=item["file_path"]
            bucket=item["bucket"]
            if "compression" in item.keys():
                compression_rates.insert(0, item["compression"])
            
            for rate in compression_rates:
            
                output=extract_barcodes(bucket, file_path, rate)
                if output["result"]!=[]:
                    return jsonify(output)
                    
        
            return jsonify(output)


if __name__ == '__main__':
    app.debug=True
    app.run(host="XXX")
    #serve(app, host="0.0.0.0", port=3105)```

Module that gets imported

from pyzbar import pyzbar
import logging

import boto3
import io
from PIL import Image

    
def resize_image(img, scale_percent=60):

    width = int(img.size[0] * scale_percent / 100)
    height = int(img.size[1] * scale_percent / 100)
    dim = (width, height)
    
    resized = img.resize(dim, Image.ANTIALIAS)
    
    return resized                                    
    
    
def read_image_from_s3(bucket, document):
    s3 = boto3.client('s3', aws_access_key_id='TATA',
                            aws_secret_access_key='FAFA',
                            region_name='Moon1')
    
    file_byte_string = s3.get_object(Bucket=bucket, Key=document)['Body'].read()
    stream = io.BytesIO(file_byte_string)
    image_out=Image.open(stream)
    
    return image_out

    
def extract_barcodes(bucket, document, compression):

    list_of_barcodes=[]
    dictionary_brian={}
    dictionary_brian["result"]=[]
    image_path="./data/1.jpg"
    image= read_image_from_s3(bucket, document)
    
    while image.size[0]*image.size[1]>50:
    
        detected_barcode = pyzbar.decode(image)
        for barcode in detected_barcode:
            if barcode.data not in list_of_barcodes:
                list_of_barcodes.append(barcode.data)
        
        image=resize_image(image, compression)
        
    
    for i,barcode in enumerate(list_of_barcodes):
       print(f"Barcode detected: {barcode}")
       dictionary_brian["result"].append(barcode.decode("utf-8"))
    #dictionary_brian["result"]=list_of_barcodes.decode("utf-8")

What i tried so far:
replicate conda environment where the flask app is running inside my docker container via requirements file, use several different container dockerfiles to build the image,