Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined behaviour in Verilated::commandArgsPlusMatch #987

Closed
veripoolbot opened this issue Oct 29, 2015 · 2 comments
Closed

undefined behaviour in Verilated::commandArgsPlusMatch #987

veripoolbot opened this issue Oct 29, 2015 · 2 comments
Labels
area: wrong runtime result Issue involves an incorrect runtine result from Verilated model resolution: fixed Closed; fixed

Comments

@veripoolbot
Copy link
Contributor


Author Name: Jamie Iles (@jamieiles)
Original Redmine Issue: 987 from https://www.veripool.org
Original Date: 2015-10-29


Verilated::commandArgsPlusMatch calls c_str() on an automatic std::string and returns that. When the application uses that memory it can be pointing to something else rather than the string. I saw this on 3.874-1 in Ubuntu Wily which happened to work on the Ubuntu Vivid version by luck.

Changing to strdup the c_str() is the least invasive change, we could use static data, but that could break applications that expect the pointer to remain valid for the life of the application. I've attached a minimal patch to do this.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-10-30T01:08:00Z


Thanks, especially for a patch. I debated for a while and decided to return a static instead, since this is unlikely to be presently used by people. Ideally it would return a string, but I don't want to include string as it would greatly harm compile speed.

Fixed in git towards 3.878.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-11-01T13:23:43Z


In 3.878.

@veripoolbot veripoolbot added area: wrong runtime result Issue involves an incorrect runtine result from Verilated model resolution: fixed Closed; fixed labels Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: wrong runtime result Issue involves an incorrect runtine result from Verilated model resolution: fixed Closed; fixed
Projects
None yet
Development

No branches or pull requests

1 participant