No person shall be excused from attending and testifying, or producing any books, papers, or other documents before any court, magistrate judge, or the United States attorney upon any investigation, proceeding or trial, for or relating to or concerned with a violation of any section of this chapter or attempt to commit such violation, upon the ground or for the reason that the testimony or evidence, documentary or otherwise, required of him may tend to convict him of a crime or to subject him to a penalty or forfeiture; but no person shall be prosecuted or subjected to any penalty or forfeiture for or on account of any transaction, matter or thing concerning which he may so testify or produce evidence, documentary or otherwise, and no testimony so given or produced shall be received against him, upon any criminal investigation, proceeding or trial, except upon a prosecution for perjury or contempt of court based upon the giving or producing of such testimony.