clab / clab/dynet

ParameterCollectionStorage::gradient_l2_norm_dev : Invalid read

Open
#1,479 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
3.4k
Forks
701
PR merge metrics
No merged PRs in 30d

Description

Hello,

I'm using dynet in C++.
When I call Trainer::update I get this call tree :

#1 0x00007ffff70fe6df in `dynet::ParameterCollectionStorage::gradient_l2_norm_dev` (this=this@entry=0xc5687c0, dev=...)
at /home/franck/Documents/dynet/dynet/model.cc:824
#2 0x00007ffff70f1443 in `dynet::ParameterCollectionStorage::gradient_l2_norm`
(this=0xc5687c0) at /home/franck/Documents/dynet/dynet/model.cc:870
#3 0x00007ffff70f1565 in `dynet::ParameterCollection::gradient_l2_norm` (
this=) at /home/franck/Documents/dynet/dynet/model.cc:874
#4 0x00007ffff750dc09 in `dynet::Trainer::clip_gradients` (this=this@entry=0xc569220)
at /home/franck/Documents/dynet/dynet/training.cc:64
#5 0x00007ffff750f001 in `dynet::Trainer::update` (this=0xc569220)
at /home/franck/Documents/dynet/dynet/training.cc:96

And in the last function that is called, namely : `dynet::ParameterCollectionStorage::gradient_l2_norm_dev` defined line 807 of model.cc, valgrind report an invalid read.

Indeed when debugging I found that in the instruction :
`if (params.size() && all_params[pi] == params[k1]) {`
line 821 of model.cc
I had `k1 == 4` and `params.size() == 4`
so the read params[k1] is out of bounds

I don't realy understand what k1 represents, and I'm not sure this affects my program behaviour.
But I'd like to understand what is causing k1 to take the value 4 while params.size() is 4.

Thanks for you help.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with dynet/model.cc around lines 807-824, then follow the call chain through training.cc lines 64 and 96. Reproduce Trainer::update under Valgrind and inspect how k1 and params are computed before the params[k1] access. Done means the out-of-bounds read is explained and no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.