Closed JulienBeg closed 2 months ago
As far as I can tell, this issue is due to the ntraces_a
variable being used in the function SASCA
while not being passed as an argument to it, defaulting to using the module-level value of that variable, which may correspond to another thread.
This doesn't seem to be scalib-related. Feel free to re-open if my analysis is wrong.
Describe the bug
Performing several SASCA in parallel with multiple threads it raises errors (randomly) The same code with one thread works. It seems that one SASCA is using the traces of the SASCA of another threads. It produces errors when the number of traces changes and is unexpected.
To Reproduce
Run the python code attached in issue.txt (which is python code) with threadings = True (line 268). When threadings = False no error should appear.
issue.txt
Observed behavior
Traceback (most recent call last): File "IssueSCALib/issue.py", line 182, in
i,j,res = future.result()
File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
return self.get_result()
File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in get_result
raise self._exception
File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "IssueSCALib/issue.py", line 167, in task
return i,j,main(std,ntraces_a,Nt,nround)
File "IssueSCALib/issue.py", line 136, in main
bp = SASCA(traces_a,labels_a,probas_RLDA,nround)
File "IssueSCALib/issue.py", line 108, in SASCA
bp.set_evidence(f"x{i}", probas[i])
File ".local/lib/python3.10/site-packages/scalib/attacks/factor_graph.py", line 287, in set_evidence
self._inner.set_evidence(var, distribution)
TypeError: Wrong number of traces for distribution: got 4, expected 63.
Environment: