Downloads · 30 days
0
ericblackgachara/caffe-oom-poc
caffe-oom-poc is a machine learning model from ericblackgachara. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
- Repo: BVLC/caffe - Platform: huntr.com - Format: .caffemodel (protobuf)
Downloads · 30 days
0
Access
Public
Updated May 10, 2026
Repo size
129 KB
Likes
0
Public
Click a slice to open those files.
.pdf129 KB · 95%
From the Hugging Face model README
.caffemodel (protobuf)The overflow guard in Blob::Reshape() has a boundary condition that allows INT_MAX through:
// src/caffe/blob.cpp:26-28
CHECK_LE(shape[i], INT_MAX / count_); // count_=1: INT_MAX <= INT_MAX → PASSES
count_ *= shape[i]; // count_ = 2,147,483,647
// blob.cpp:34-35
data_.reset(new SyncedMemory(capacity_ * sizeof(Dtype))); // ~8 GB — NO CAP
diff_.reset(new SyncedMemory(capacity_ * sizeof(Dtype))); // ~8 GB — NO CAP
Total allocation attempt: ~16 GB → std::bad_alloc / OOM-kill.
caffe.Net('deploy.prototxt', 'caffe_oom.caffemodel', caffe.TEST)
→ Net::CopyTrainedLayersFrom() [net.cpp:991]
→ Blob::FromProto(proto, reshape=true) [blob.cpp:285]
→ Blob::Reshape(vector<int>) [blob.cpp:21]
→ new SyncedMemory(8,589,934,588) [blob.cpp:35]
→ CaffeMallocHost(8589934588)
→ malloc() → ENOMEM → std::bad_alloc → SIGABRT
| File | Line | Issue |
|---|---|---|
src/caffe/blob.cpp | 26-28 | Boundary case: guard passes for shape[i]=INT_MAX, count_=1 |
src/caffe/blob.cpp | 34-35 | SyncedMemory alloc with no size cap |
src/caffe/net.cpp | 1014 | FromProto(reshape=true) triggers allocation |
poc_caffe_oom.py — builds caffe_oom.caffemodel and documents triggercaffe_oom.caffemodel — generated by scriptpython poc_caffe_oom.py
# With caffe bindings:
import caffe
caffe.Net('deploy.prototxt', 'caffe_oom.caffemodel', caffe.TEST)
constexpr int64_t kMaxBlobCount = 1LL << 28; // 256M elements
CHECK_LE(count_, kMaxBlobCount) << "blob size exceeds safe limit";