René's URL Explorer Experiment


Title: SoftwareSerial bug - local variable, dangling pointer · Issue #19 · avaldebe/PMserial · GitHub

Open Graph Title: SoftwareSerial bug - local variable, dangling pointer · Issue #19 · avaldebe/PMserial

X Title: SoftwareSerial bug - local variable, dangling pointer · Issue #19 · avaldebe/PMserial

Description: I look at this code and see an error (explain in cppreference). The variable serial is local (in stack), its lifetime is limited to the area of the constructor. After exiting the constructor, the variable serial will be destroyed, and th...

Open Graph Description: I look at this code and see an error (explain in cppreference). The variable serial is local (in stack), its lifetime is limited to the area of the constructor. After exiting the constructor, the v...

X Description: I look at this code and see an error (explain in cppreference). The variable serial is local (in stack), its lifetime is limited to the area of the constructor. After exiting the constructor, the v...

Opengraph URL: https://github.com/avaldebe/PMserial/issues/19

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SoftwareSerial bug - local variable, dangling pointer","articleBody":"I look at [this code](https://github.com/avaldebe/PMserial/blob/98ccdffcfd50219e522fd0830552d082bae824e7/src/PMserial.h#L88) and see an error ([explain in cppreference](https://en.cppreference.com/w/cpp/language/reference#Dangling_references)).\r\nThe variable `serial` is local (in stack), its lifetime is limited to the area of the constructor. After exiting the constructor, the variable `serial` will be destroyed,  and the variable `uart` will contain [dangling pointer](https://en.wikipedia.org/wiki/Dangling_pointer). Copying its address should not prolong the lifetime.\r\n\r\nI tried looking for some special case that affects the lifetime of a variable and which will not be \"undefined behavior\" ([0](https://en.cppreference.com/w/cpp/language/lifetime), [1](https://en.cppreference.com/w/cpp/language/reference#Dangling_references), [2](https://en.cppreference.com/w/cpp/language/reference_initialization#Lifetime_of_a_temporary), [3](https://stackoverflow.com/questions/22114751/returning-static-pointer-to-local-variable-from-function), [4](https://qna.habr.com/q/246744), [5](https://habr.com/ru/company/jugru/blog/469465/), [6](https://habr.com/ru/post/186790/) ). But I couldn't find anything suitable for this code...\r\n\r\nIf my fears are in vain, please give me a link to a description of this case in the standard or explain how it works.\r\n\r\nProblem code:\r\n```\r\nclass SerialPM\r\n{\r\nprotected:\r\n  Stream *uart;  // hardware/software serial\r\n....\r\n\r\n  SerialPM(PMS sensor, uint8_t rx, uint8_t tx) : pms(sensor)\r\n  {\r\n    SoftwareSerial serial(rx, tx);\r\n    uart = \u0026serial;\r\n    hwSerial = false;\r\n  }\r\n```\r\n","author":{"url":"https://github.com/heX16","@type":"Person","name":"heX16"},"datePublished":"2021-02-28T23:36:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/19/PMserial/issues/19"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:451d1ab3-533e-3be0-f5d8-5ccbca04cffb
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA912:2EFA45:59A8BE:7FE69A:6A4BCC86
html-safe-nonce4c173f5923a9b2a4f068a772b064e9d2750b00b10d3b398fd6fae40accad03a9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTEyOjJFRkE0NTo1OUE4QkU6N0ZFNjlBOjZBNEJDQzg2IiwidmlzaXRvcl9pZCI6IjM3NTQzNTk5ODc1NzQxMzE4NDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac3902a1a8886448b120360625ae166a91c9a5dffc74c2a96c89ae31405ddcbe60
hovercard-subject-tagissue:818343704
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/avaldebe/PMserial/19/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ea82843067115e65f483b141799d64c49d5443fba25369e541523f2cf0695780/avaldebe/PMserial/issues/19
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ea82843067115e65f483b141799d64c49d5443fba25369e541523f2cf0695780/avaldebe/PMserial/issues/19
og:image:altI look at this code and see an error (explain in cppreference). The variable serial is local (in stack), its lifetime is limited to the area of the constructor. After exiting the constructor, the v...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameheX16
hostnamegithub.com
expected-hostnamegithub.com
None14aa00ce5bdb34d0eefb5facbffd7de9e144c688d8a93ef8df902d5f94b51dd7
turbo-cache-controlno-preview
go-importgithub.com/avaldebe/PMserial git https://github.com/avaldebe/PMserial.git
octolytics-dimension-user_id8268218
octolytics-dimension-user_loginavaldebe
octolytics-dimension-repository_id108874855
octolytics-dimension-repository_nwoavaldebe/PMserial
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id108874855
octolytics-dimension-repository_network_root_nwoavaldebe/PMserial
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release58b8f89190447502561829f30862aa0a99d53367
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/avaldebe/PMserial/issues/19#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Favaldebe%2FPMserial%2Fissues%2F19
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Favaldebe%2FPMserial%2Fissues%2F19
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=avaldebe%2FPMserial
Reloadhttps://github.com/avaldebe/PMserial/issues/19
Reloadhttps://github.com/avaldebe/PMserial/issues/19
Reloadhttps://github.com/avaldebe/PMserial/issues/19
avaldebe https://github.com/avaldebe
PMserialhttps://github.com/avaldebe/PMserial
Notifications https://github.com/login?return_to=%2Favaldebe%2FPMserial
Fork 23 https://github.com/login?return_to=%2Favaldebe%2FPMserial
Star 58 https://github.com/login?return_to=%2Favaldebe%2FPMserial
Code https://github.com/avaldebe/PMserial
Issues 1 https://github.com/avaldebe/PMserial/issues
Pull requests 0 https://github.com/avaldebe/PMserial/pulls
Discussions https://github.com/avaldebe/PMserial/discussions
Actions https://github.com/avaldebe/PMserial/actions
Projects https://github.com/avaldebe/PMserial/projects
Security and quality 0 https://github.com/avaldebe/PMserial/security
Insights https://github.com/avaldebe/PMserial/pulse
Code https://github.com/avaldebe/PMserial
Issues https://github.com/avaldebe/PMserial/issues
Pull requests https://github.com/avaldebe/PMserial/pulls
Discussions https://github.com/avaldebe/PMserial/discussions
Actions https://github.com/avaldebe/PMserial/actions
Projects https://github.com/avaldebe/PMserial/projects
Security and quality https://github.com/avaldebe/PMserial/security
Insights https://github.com/avaldebe/PMserial/pulse
SoftwareSerial bug - local variable, dangling pointerhttps://github.com/avaldebe/PMserial/issues/19#top
bughttps://github.com/avaldebe/PMserial/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/heX16
heX16https://github.com/heX16
on Feb 28, 2021https://github.com/avaldebe/PMserial/issues/19#issue-818343704
this codehttps://github.com/avaldebe/PMserial/blob/98ccdffcfd50219e522fd0830552d082bae824e7/src/PMserial.h#L88
explain in cppreferencehttps://en.cppreference.com/w/cpp/language/reference#Dangling_references
dangling pointerhttps://en.wikipedia.org/wiki/Dangling_pointer
0https://en.cppreference.com/w/cpp/language/lifetime
1https://en.cppreference.com/w/cpp/language/reference#Dangling_references
2https://en.cppreference.com/w/cpp/language/reference_initialization#Lifetime_of_a_temporary
3https://stackoverflow.com/questions/22114751/returning-static-pointer-to-local-variable-from-function
4https://qna.habr.com/q/246744
5https://habr.com/ru/company/jugru/blog/469465/
6https://habr.com/ru/post/186790/
bughttps://github.com/avaldebe/PMserial/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.